On 08/18/10 04:50, Cameron Simpson wrote:
("nikos",) is a single element tuple.
["nikos"] is a single element list.
["nikos",] is also a single element list, just written like the tuple.

You don't see the ["nikos",] form very often because ["nikos"] is not
ambiguous.

I most frequently see/use the trailing comma in a one-item list when I expect additional items will be accrued later, so it makes my version-control diffs tidier:

  items = [
   "nikos",
   ]

Then a month later, I add

  items = [
   "nikos",
   "cameron",
   ]

My diff is just

   items = [
    "nikos",
+   "cameron",
    ]

which is quite easy to understand.  However if my original was

  items = [
   "nikos"
   ]

and I later want to make it


  items = [
   "nikos",
   "cameron"
   ]

the diff then becomes

   items = [
-   "nikos"
+   "nikos",
+   "cameron"
    ]

which isn't nearly as easy to read & understand because I now have to notice the inter-linear differences ("did something more than the new-comma happen?").

-tkc





--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to