Why would I get a TypeEror?

Peter Hansen peter at engcorp.com
Wed Jan 12 12:57:42 EST 2005


It's me wrote:
> For this code snip:
> 
> a=3
> ....
> b=(1,len(a))[isinstance(a,(list,tuple,dict))]
> 
> Why would I get a TypeError from the len function?

What did you expect the "length" of the integer 3 to be?

-Peter



More information about the Python-list mailing list