Sujet : Re: Python (was Re: I did not inhale)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.unix.shell comp.unix.programmer comp.lang.miscDate : 30. Aug 2024, 00:03:54
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vaquop$5ioe$2@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
User-Agent : Pan/0.160 (Toresk; )
On Thu, 29 Aug 2024 14:01:05 +0200, David Brown wrote:
On 29/08/2024 02:23, Keith Thompson wrote:
>
Lawrence D'Oliveiro <ldo@nz.invalid> writes:
>
On Wed, 28 Aug 2024 13:29:18 -0700, Keith Thompson wrote:
>
But ok, I found your post and removed all the #end comments. I found
it just as readable without them as with them.
>
You know what? You are right. That example was just too
well-structured.
So why not try to write /all/ your code in a well-structured manner, so
that you don't feel the need to add these "#end" comments?
Because not all examples can be made that neat, as I demonstrated.
def register_additional_standard(self, managed_objects) :
"""
registers additional standard interfaces that are not
automatically installed at Connection creation time. Currently
the only one is the object-manager interface, registered with
>
«conn».register_additional_standard(managed_objects = True)
"""
Note that Python’s indentation rules don’t apply to multiline string
literals -- don’t you wish they did? So you end up with all that extra
space within the literal. Do you see why I prefer to avoid that?
Line continuation characters in Python are usually an indicator of poor
formatting, or an unhealthy obsession with line length limits.
I like to keep within a line length limit of about 100 characters.
I don't know if I am more experienced than you in Python (I may have
been using Python for longer, but you may have worked with it more), but
I would say that the "#end" comments directly detract from readability.
Think about why you bother to indent code in languages where the compiler
ignores such indentation anyway: it means you are expressing the structure
of code in two different ways, one via statement brackets, and the other
via indentation. This redundancy aids in understanding that the code does
what you think it does.
Python gets rid of this redundancy, by having the compiler take notice of
the whitespace and removing the statement bracketing symbols. So I put it
back, by adding statement bracketing symbols that the compiler ignores.