Sujet : Re: Writing Python Code More Concisely Than Perl!?
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.misc comp.programmingDate : 17. Jun 2025, 00:07:46
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <102q842$1u86q$1@dont-email.me>
References : 1 2 3 4 5 6 7 8
User-Agent : Pan/0.162 (Pokrosvk)
On Mon, 16 Jun 2025 18:34:56 +0100, Brian Morrison wrote:
I still struggle with syntax that needs indents to be there rather
than simply being a reading aid.
After my first few months of writing Python, I decided to start
putting in “#end” comments to mark the ends of compound statements.
E.g.
def mapiter(self, pts) :
"maps an iterable of Vectors through the Matrix."
pts = iter(pts)
while True :
try :
yield self.map(next(pts))
except StopIteration :
break
#end try
#end while
#end mapiter
In conventional languages you have redundancy between the use of
statement brackets (which the compiler understands) versus indentation
(which the compiler ignores but the human understands). Python got rid
of this redundancy, so I put it back with the “#end” comments as the
cue that the compiler ignores but the human understands.
I also have custom commands defined in Emacs to jump between lines
with matching indentation. This lets me quickly navigate between the
beginnings and ends of compound statements.