On 12.01.2005, at 18:35, 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?

because len() works only for sequence and mapping objects:

>>> help(len)
Help on built-in function len in module __builtin__:

len(...)
    len(object) -> integer

    Return the number of items of a sequence or mapping.

- harold -

--
Ceci n'est pas une signature.
--

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

Reply via email to