String substitution VS proper mysql escaping

Tim Chase python.list at tim.thechases.com
Wed Aug 18 06:45:37 EDT 2010


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








More information about the Python-list mailing list