Re: Writing Python Code More Concisely Than Perl!?

Liste des GroupesRevenir à l misc 
Sujet : Re: Writing Python Code More Concisely Than Perl!?
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.misc comp.programming
Date : 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.

Date Sujet#  Auteur
14 Jun 25 * Re: Writing Python Code More Concisely Than Perl!?16c186282
14 Jun 25 `* Re: Writing Python Code More Concisely Than Perl!?15Keith Thompson
15 Jun 25  `* Re: Writing Python Code More Concisely Than Perl!?14c186282
15 Jun 25   `* Re: Writing Python Code More Concisely Than Perl!?13Keith Thompson
15 Jun 25    +* Re: Writing Python Code More Concisely Than Perl!?7Brian Morrison
15 Jun 25    i+* Re: Writing Python Code More Concisely Than Perl!?3Keith Thompson
16 Jun 25    ii`* Re: Writing Python Code More Concisely Than Perl!?2Brian Morrison
16 Jun 25    ii `- Re: Writing Python Code More Concisely Than Perl!?1Keith Thompson
15 Jun 25    i`* Re: Writing Python Code More Concisely Than Perl!?3Lawrence D'Oliveiro
16 Jun 25    i `* Re: Writing Python Code More Concisely Than Perl!?2Brian Morrison
17 Jun 25    i  `- Re: Writing Python Code More Concisely Than Perl!?1Lawrence D'Oliveiro
18 Jun 25    `* Re: Writing Python Code More Concisely Than Perl!?5c186282
18 Jun 25     `* Re: Writing Python Code More Concisely Than Perl!?4Keith Thompson
19 Jun 25      `* Re: Writing Python Code More Concisely Than Perl!?3Keith Thompson
20 Jun 25       `* Re: Writing Python Code More Concisely Than Perl!?2c186282
20 Jun 25        `- Re: Writing Python Code More Concisely Than Perl!?1Keith Thompson

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal