venkata subramanian wrote:
> If you have any doubts,
> try to remeber this when creating tuples,
>
> if a tuple is to have 0 elements,
> then it must be given as a=()
> in other words, the ( and the ) are essential
>
> if it has one element,
> then a comma after that element is essential
> a=1,
If you have any doubts,
try to remeber this when creating tuples,
if a tuple is to have 0 elements,
then it must be given as a=()
in other words, the ( and the ) are essential
if it has one element,
then a comma after that element is essential
a=1,
or alternatively
a=(1,)
in other words, an end
Hi All--
This little gotcha ought to be number one on "The Official List of
Pythonic Gotchas," which should be required reading for everyone.
What? There isn't one? Why not?
Send me your tired, your poor, your huddled gotchas yearning to breathe
free. I'll whup 'em into shape and make a doc pa
Just as everyone said, use ('a',) instead of ('a'). As Steve said there
are lots of documentation about it. Check the Library Reference at
http://www.python.org/doc/current/lib/typesseq.html#l2h-155 or to make
things more clear you could read the tuples section in the tutorial at
http://docs.python
flyaflya wrote:
>
> >>> a = {1: ("a")}
> >>> a[1]
> 'a'
> why not ('a')? when
> >>> a = {1: ((("a")))}
> >>> a[1]
> 'a'
> the result is 'a' too,not ((("a"))).but when use["a"] or ("a","b"),the
> tuple is longer than 1, it's no problem.
>
>
>
To define a tuple literal with one member, you
Hallöchen!
flyaflya <[EMAIL PROTECTED]> writes:
a = {1: ("a")}
a[1]
> 'a'
> why not ('a')?
("a") is not a tuple, but ("a",) is.
Tschö,
Torsten.
--
Torsten Bronger, aquisgrana, europa vetus
--
http://mail.python.org/mailman/listinfo/python-list
flyaflya wrote:
>
> >>> a = {1: ("a")}
> >>> a[1]
> 'a'
> why not ('a')? when
> >>> a = {1: ((("a")))}
> >>> a[1]
> 'a'
> the result is 'a' too,not ((("a"))).but when use["a"] or ("a","b"),the
> tuple is longer than 1, it's no problem.
>
>
("a") is just a simple expression. You need to add