Trailing comma (was: Re: structure in Python)
Peter Hansen
peter at engcorp.com
Tue Oct 21 12:01:32 EDT 2003
Cousin Stanley wrote:
>
> >>>
> >>> x = [ 'fe' , 'fi' 'fo' , 'fum' , ]
> >>>
> >>> print "we have", len(x), "thingies"
> we have 3 thingies
>
> Alex ....
>
> I don't understand how an extra comma at the end
> of a sequence is supposed to help with problems
> like this where a sequence delimeter, the comma,
> has been ommitted in the middle of the sequence ....
Note that Alex' list was not all on one line, as you have
reformatted it above. In such a case, I would not include
the trailing comma.
In the case of lists formatted with one item per line, I
now always include the trailing comma for just the maintenance
reasons Alex mentions. This is certainly a case where I've
been burned often enough in (older) C because you *could not*
do that, and I'm happy to have it in Python and, now, in C.
-Peter
More information about the Python-list
mailing list