TypeError: iterable argument required

eryksun () eryksun at gmail.com
Wed Apr 6 17:08:26 EDT 2011


On Wednesday, April 6, 2011 3:21:42 PM UTC-4, Νικόλαος Κούρας wrote:
> On 6 Απρ, 19:58, "eryksun ()" <ery... at gmail.com> wrote:
> 
> > The expression ``x or y`` first evaluates *x*; if *x* is
> > true, its value is returned; otherwise, *y* is evaluated
> > and the resulting value is returned.
> 
> I doesnt matter if *y* is True or False before its value is returned?
> *y*'s value returned no matter if its true or false?

In general *y* is an expression that gets evaluated down to some object that gets returned:

In [1]: type(False or (3-3))
Out[1]: <type 'int'>

In this case the int equals 0, which is False in a boolean context:

In [2]: bool(False or (3-3))
Out[2]: False

> >Since 'mail is None' and None evaluates to False
> 
> What does the expression "None evaluates to false"  mean in simpler
> words? Every expression is evaluated at the end as True or False?

It means bool(None) is False. In (x or y), the expression y will only be evaluated if bool(x) is False. If bool(x) evaluates to True, then the operation short circuits to return x without evaluating y.



More information about the Python-list mailing list