Tuple Syntax and ()
James Stroud
jstroud at ucla.edu
Tue Jun 13 15:34:21 EDT 2006
tactics40 at gmail.com wrote:
> I keep accidently trying to declare t-tuples as mytuple = (myitem)
>
> I know this doesn't work and that you need the trailing comma, but
> reading something online, I just came to realize.... the parenthesises
> don't have any special meaning in relation to tuples at all, do they?
>
Aside from grouping, they are special to construct an empty tuple.
py> () == tuple()
True
Also, don't underestimate their relationship with tuples when it comes
to grouping:
py> a, b, c = 1, 2, 3
py>
py> a == a, b, c
(True, 2, 3)
py> a == (a, b, c)
False
James
--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095
http://www.jamesstroud.com/
More information about the Python-list
mailing list