Question about tuple lengths
larry.bates at websafe.com
Thu Dec 15 19:31:33 CET 2005
Carl J. Van Arsdall wrote:
> From my interpreter prompt:
>>>> tuple = ("blah")
>>>> tuple2 = ("blah",)
>>>> len (tuple2)
> So why is a tuple containing the string "blah" without the comma of
> length four? Is there a good reason for this or is this a bug?
You should not give a tuple a variable name of tuple, it masks
the built-in tuple() function. This also goes for str, or other
built-ins. This will "bite" you at some point if it hasn't already.
More information about the Python-list