Trailing comma

Georgy Pruss SEE_AT_THE_END at hotmail.com
Tue Oct 21 18:15:01 EDT 2003


"Timo Virkkala" <a at a.invalid> wrote in message news:bn415p$u9s$1 at nyytiset.pp.htv.fi...
> Alex Martelli wrote:
>
> > Timo Virkkala wrote:
> >>Ben Caradoc-Davies wrote:
> >>>    d = {
> >>>        "A": [1, 5],
> >>>        "B": [6, 7],  # last trailing comma is optional but good style
> >>>    }
> >>Why is it considered good style? I mean, I understand that it's easier
> >>to later add a new line, but...
> [snip]
> > Learning to use different style in SQL is not going to be difficult,
> > because it's such a hugely different language from all of these
> > anyway.  Are you afraid to use a * for multiplication because it may
> > confuse you to write 'select * from ...'?-)
>
> Touché. =)
>
> > Plus, there are errors which are either diagnosed by the computer
> > or innocuous (extra commas are typically that way), and others which
> > are NOT diagnosed and can be terribly dangerous (missing commas may be).
> > E.g., consider:
> >
> > x = [
> >   "fee",
> >   "fie"
> >   "foo",
> >   "fum"
> > ]
>
> A good example. I didn't spot that on the first look.
>
> Maybe I should get into the habit of always including the trailing comma
> and see where I get. Before this I didn't even know that it was allowed.
>
> --
> Timo Virkkala
>

Another "solution" is just to look at the previous line and check if it has the comma
or not. You'd better get a habit to THINK and not do things mechanically, as others
suggest.

-- 
Georgy Pruss
E^mail: 'ZDAwMTEyMHQwMzMwQGhvdG1haWwuY29t\n'.decode('base64')






More information about the Python-list mailing list