How to force a single number to be a tuple

Peter Otten __peter__ at web.de
Wed Aug 4 13:18:49 EDT 2004


Gandalf wrote:

>>y = (2,)
>>
> Funky. However, very logical. You can also write:

>>> () == (,)
  File "<stdin>", line 1
    () == (,)
           ^
SyntaxError: invalid syntax
>>> (1) == (1,)
False
>>> (1, 2) == (1, 2,)
True
>>>

Very logical indeed...

> Python is the best. :-)

Of course, the above not withstanding :-)

Peter




More information about the Python-list mailing list