Why tuple with one item is no tuple
Tim Roberts
timr at probo.com
Wed Mar 16 02:54:35 EST 2005
Gregor Horvath <g.horvath at mx.at> wrote:
>
> >>>type(['1'])
><type 'list'>
>
> >>>type(('1'))
><type 'str'>
>
>I wonder why ('1') is no tuple????
There were lots of answers, but I'm not sure I saw the "why" addressed.
Consider this:
a = (3 + 5) * 5
You really, really want (3 + 5) to be an integer, not a one-item tuple.
--
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list