I'm searching for Python style guidelines

Paul McGuire ptmcg at austin.rr.com
Mon Jan 7 19:33:14 CET 2008

On Jan 7, 12:26 pm, MartinRineh... at gmail.com wrote:
> Guilherme Polo wrote:
> > foo = [
> >     'too long',
> >     'too long too',
> >     ...
> >     ]
> OK, I'll put it there too, and it will be easy for us to read each
> other's code (at least in this particular).

While not required by any means, you will also find it handy to follow
*every* entry in the list with a comma, even the last one in the list
(this is legal Python).  That is, in your example:

 foo = [
     'too long',
     'too long too',
     'too long too',
     'last item',

Later on when you want to reorder the items, then you can just copy/
paste whole lines, even if moving to or from the bottom of the list.
This is also a good argument for putting the closing ']' on its own
line, instead of on the same line as the last item.

-- Paul

More information about the Python-list mailing list