Sorry if my question was a little "lazy" and yes, I was asking about the "lazy evaluation". :=)
I am surprised about this (and this can be dangerous, I guess). If this is true, I would run into trouble real quick if I do a: (1/x,1.0e99)[x==0] and that's not good. Something to keep in mind. :-( "harold fellermann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > 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? > > the problem is, that (1,len(a)) is evaluated, neither what type a > actually has > (python has no builtin lazy evaluation like ML). You have to do it this > way > instead: > > a=3 > ... > b = isinstance(a,(list,tuple,dict)) and len(a) or 1 > > - harold - > > -- > The opposite of a correct statement is a false statement. > But the opposite of a profound truth may be another profound truth. > -- Niels Bohr > -- http://mail.python.org/mailman/listinfo/python-list