TypeError: iterable argument required

MRAB python at mrabarnett.plus.com
Wed Apr 6 15:44:30 EDT 2011

On 06/04/2011 20:21, Νικόλαος Κούρας wrote:
> On 6 Απρ, 19:58, "eryksun ()"<eryk... 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?
> If we were to describe it in english words how would we describe the
> expression `x or y`?
> x = True or y = True?
>> 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?

For `x or y`, if `bool(x)` is True, it returns `x`, else it returns `y`.

For `x or y or z`, if `bool(x)` is True, it returns `x`, else if
`bool(y)` is True, it returns `y`, else it returns `z`.

And so on.

In Python, the convention is for certain things to be regarded as False
(bool(thing) returns False) and everything else to be regarded as True
(bool(thing) returns True).

'False' things include None, empty strings, empty containers (empty 
list, etc), and zero.

'True' things include non-empty strings, non-empty containers, and 
non-zero numbers.

When in doubt, ask Python:

 >>> bool([])
 >>> bool("Hello world!")

More information about the Python-list mailing list