Why tuple with one item is no tuple
James Stroud
jstroud at mbi.ucla.edu
Tue Mar 15 13:47:28 EST 2005
On Tuesday 15 March 2005 08:25 am, Roy Smith wrote:
> a = () # tuple of zero elements
> a = (1,) # tuple of one element
> a = 1, # tuple of one element
> a = (1) # scalar
> a = (1, 2) # tuple of two elements
> a = 1, 2 # tuple of two elements
> a = , # syntax error
>
> The big question is, is it the parens that make it a tuple, or is it
> the comma? If you go along with the parens school of thought, then
> (1,) is the special case. If you believe in commas, then the () is
> the special case. In either case, it's a bit ugly, but we learn to
> overlook the occasional cosmetic blemishes of those we love :-)
The answer is obvious, the naked comma should be an empty tuple.
--
James Stroud, Ph.D.
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
More information about the Python-list
mailing list