one-element tuples [Was: Most probably a stupid question, but I still want to ask]
Tim Chase
python.list at tim.thechases.com
Sun Apr 10 20:46:35 EDT 2016
On 2016-04-11 01:33, MRAB wrote:
> A one-element tuple can be written as:
>
> >>> ('hello',)
> ('hello',)
>
> As has been said already, it's the comma that makes the tuple. The
> parentheses are often needed to avoid ambiguity.
Except when the comma *doesn't* make the tuple:
>>> t = ()
>>> type(t)
<class 'tuple'>
;-)
-tkc
More information about the Python-list
mailing list