String substitution VS proper mysql escaping

Stefan Schwarzer sschwarzer at
Thu Aug 19 13:41:11 CEST 2010

Hi Νίκος,

On 2010-08-19 09:10, Νίκος wrote:
> On 18 Αύγ, 12:50, Cameron Simpson <c... at> 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
> commas?

Because parentheses are also used to group expressions.
For example,

>>> 2 * (1+2)

If it were as you would like, the result would have been

(3, 3)

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 mailing list