[1,2,3] exactly same as [1,2,3,] ?

Grant Edwards grante at visi.com
Fri Aug 29 16:45:00 CEST 2008


On 2008-08-29, Roy Smith <roy at panix.com> wrote:

> Exactly.  This is one of those little pieces of syntactic
> sugar which makes python so nice to work with.  The
> alternative is (in C, for example) abominations like this:
>
> const char* l[] = {"foo"
>                  , "bar"
>                  , "baz"
>                  };
>
> and even those are not quite as good because you still have to
> special-case the first entry.

It's probably a spec violation, but I've never seen a C
compiler that objected to a comma after the last item in an
initializer list.  (At least not at the warning levels I use,
which tend to be on the picky side.)

-- 
Grant Edwards                   grante             Yow! There's enough money
                                  at               here to buy 5000 cans of
                               visi.com            Noodle-Roni!



More information about the Python-list mailing list