maybe a bug in python

Will McGugan news at NOwillmcguganSPAM.com
Sun Jun 5 12:42:28 EDT 2005


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 a comma so that 
Python knows you want a tuple. Thusly... ("a",)


Will McGugan
-- 
http://www.willmcgugan.com
"".join({'*':'@','^':'.'}.get(c,0) or chr(97+(ord(c)-84)%26) for c in 
"jvyy*jvyyzpthtna^pbz")



More information about the Python-list mailing list