on = style

Steve D'Aprano steve+python at pearwood.info
Mon Oct 9 03:46:56 EDT 2017


On Mon, 9 Oct 2017 05:56 pm, Stefan Ram wrote:

> Abdur-Rahmaan Janhangeer <arj.python at gmail.com> writes:
>>hi just a quick question, why is
> 
>   When you post a new question, you should start a new thread.
>   Your post already has many other posts in the References header.
> 
>>my_pens = 4
>>my_pencils = 5
>>is preffered to
>>my_pens    = 4
>>my_pencils = 5
> 
>   "preferred"
> 
>   The rationale is not clear to me. Could be:
> 
> abc                                  = 2
> def                                  = 3
> ghi                                  = 4
> jkl                                  = 5
> mno                                  = 6
> pqr                                  = 7
> stu                                  = 8
> vwx                                  = 9
> abcdefghijklmnopqrstuvwxyzabcdefghij = 0

And then when you add another line:

abcdefghijklmnopqrstuvwxyzabcdefghijαβγδεζηθικλμ = 1

you have to waste time lining everything up again:


abcdefghijklmnopqrstuvwxyzabcdefghij[αβγδεζηθικλμ] = 1
abc                                               = 2
def                                               = 3
ghi                                               = 4
jkl                                               = 5
mno                                               = 6
pqr                                               = 7
stu                                               = 8
vwx                                               = 9
abcdefghijklmnopqrstuvwxyzabcdefghij              = 0

And then later you decide that's a damn ridiculously long line, so you split
it over two:

abcdefghijklmnopqrstuvwxyzabcdefghij[
            αβγδεζηθικλμ] = 1
abc                                               = 2
def                                               = 3
ghi                                               = 4
jkl                                               = 5
mno                                               = 6
pqr                                               = 7
stu                                               = 8
vwx                                               = 9
abcdefghijklmnopqrstuvwxyzabcdefghij              = 0


so now you waste MORE time aligning things:


abcdefghijklmnopqrstuvwxyzabcdefghij[
            αβγδεζηθικλμ]             = 1
abc                                   = 2
def                                   = 3
ghi                                   = 4
jkl                                   = 5
mno                                   = 6
pqr                                   = 7
stu                                   = 8
vwx                                   = 9
abcdefghijklmnopqrstuvwxyzabcdefghij  = 0


and so it continues. Not only are wasting time, but you make the version
control diffs less useful.

And the end result is, it becomes much easier to misread one of the lines and
accidentally read "mno = 7" instead of 6 and get yourself confused.

Assignment values should be close to their variable, not waaaaaaaaaaaaaaaaaay
over on the far side of the line.


>   The distance between »jkl« and »5« might make it more
>   difficult to read which value belongs to which name.

There is no "might", it definitely makes reading harder.

>   Also, sometimes people like to use automated formatting
>   tools, and they will usually remove such formatting anyway.
> 
>   And possibly some people think that it must take time
>   of the programmer to create and maintain such an alignment,
>   time in which he is not programming "productively".

There's no question about that. I've done it myself, spent five minutes
carefully lining up (for example) a dict and arranging things Just Perfectly:

mydict = dict(a   = 1234,         b   = 123,         c   = 123,
              de  = 12,           fgh = 1,           ij  = 12345,
              klm = 123456789,    n   = 12345678901, opq = 1,
              )

and then half an hour later, decide that, no, it is better to sort the items
in rows, not columns, so then I spend another ten minutes re-arranging my
Perfectly Laid Out dict:

mydict = dict(a   = 1234,         de  = 12,         klm = 123456789,
              b   = 123,          fgh = 1,          n   = 12345678901,
              c   = 123,          ij  = 12345,      opq = 1,
              }

and then the next day I decide that, no, it was better the first way, so I
spend another ten minutes re-aligning the rows and columns. And *then* I
decide that some of the keys are badly named, and I need to change them, and
that requires another re-alignment.

And then I decide that I need another key, so its no longer a perfect 3x3
square. Should I re-arrange it to a 5x2 or 2x5 rectangle? Obviously I must
try both.

(If you think I am exaggerating or making this up, I'm not.)

Eventually, after spending multiple hours (spread over a couple of days)
dicking around, I finally cannot avoid the truth any more, and have to admit
to myself that I'm just dicking around and this isn't productive work, it's
busy-work to make me look busy while actually avoiding doing anything
important but necessary, like fixing a bug.

Its even less productive and less useful than spending hours dicking around on
Usenet arguing about the number of angels that can dance on a reference.

Aligning assignments like this is an easy no-brainer activity. You are
avoiding doing anything *hard* like fixing bugs, writing documentation, or
adding new features, while actually doing something mindlessly simple that
takes no real effort.

I truly believe that, with *very* few exceptions (*ALL* of which are some form
of in-line data table, and even then only rarely) any programmer who worries
about lining up assignments on different lines like this is just engaged in a
time-wasting exercise to make themselves look busy while actually taking it
easy. It is a pure avoidance activity.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list