String substitution VS proper mysql escaping
sschwarzer at sschwarzer.net
Thu Aug 19 13:41:11 CEST 2010
On 2010-08-19 09:10, Νίκος wrote:
> On 18 Αύγ, 12:50, Cameron Simpson <c... at zip.com.au> 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.
> It makes more sense if i:
> "nikos" is just a string
> ("nikos") is a single element tuple
> ["nikos"] is also a single element list
> After all () used to define tuples and  usedd to define lists. Why
Because parentheses are also used to group expressions.
>>> 2 * (1+2)
If it were as you would like, the result would have been
So because <something_without_commas> inside parentheses
already denotes an expression you have to add a comma to
distinguish a one-element tuple from an expression.
More information about the Python-list