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 must place a comma 
after the first element like this:

a = {1: ("a",)}

I read this somewhere in the python docs, so I know its there 
somewhere.

The comma eliminates ambiguity as to the meaning of the brackets, 
which without the comma are simply enclosing and precedence 
controlling brackets.

Steve
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to