python-dev summary, July 16-31

François Pinard pinard at iro.umontreal.ca
Thu Aug 9 18:31:46 EDT 2001


[Peter Hansen]

> François Pinard wrote:
> > Really?  You write parentheses all the time?

> No, just when I write tuples!  <wink> Yes, I *definitely* use parentheses
> around tuples all the time.
>  (a) One obvious way to do things.
>  (b) I never knew there was another way at first, and the habit stuck.
>  (c) Fits my brain better, since I see parentheses and think "tuple".
>      (My brain has to pause, perhaps, when a function with arguments 
>       is called.  I don't notice the pause, apparently. :-)

But in fact, your brain comes to just accept the magic of writing without
parentheses, not having to resort all the time to explicit tuple packing and
unpacking.  Not that you forget how things work, of course, but both your
writings and mind get a bit less encumbered.  Let's take a small example.
It is so simple to write:

   dictionary[index1, index2] = value

everywhere, in those applications where "dictionary" is to be indexed
with a 2-tuple.  Just think as an associative array with two indexes,
it's easier.  We do know that there is only one index deep down, and that
tuple packing occurs.  But this is all part of the Python built-in mechanics,
which you would underline by writing:

   dictionary[(index1, index2)] = value

Do we really need to stress the inner workings everywhere?  It is more
relaxing to avoid doing so.  And Python looks even more powerful! :-)

> > Of course, for many languages, parentheses could be effectively used to
> > increase legibility.  But for marking tuples, Python does not need them
> > in most cases, it may be more noisy than useful having them to mark tuples
> > when it is not required to do so.

> You haven't convinced me yet, other than the "slightly less noise"
> argument.

I'm not really trying to convince you, as stylistic issues are often prone to
religious feelings.  On the other hand, it is often good to compare styles.
My own style improved faster, when I started to look at what others do.
We pick and absorb little things that we like, here and there.

> To do otherwise would be inconsistent, and to me 
>    (inconsistency == unmaintainability) .

Quite agreed.  I'm very sensitive to inconsistent style when I read code,
it hurts the pleasure I have to read, and I'm torn between the the desire to
report these things, and the feeling people would badly receive my comments.

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard




More information about the Python-list mailing list