TypeError: iterable argument required

Eric Snow ericsnowcurrently at gmail.com
Wed Apr 6 18:12:35 CEST 2011


Hi,

The "or" expression will return the first element that evaluates to True, or
the last element if they all evaluate to False.  Positive integers evaluate
to True.  None evaluates to False.

See:  http://docs.python.org/library/stdtypes.html#truth-value-testing

<http://docs.python.org/library/stdtypes.html#truth-value-testing>-eric

2011/4/6 Νικόλαος Κούρας <nikos.kouras at gmail.com>

> >>> mail = None
> >>> mail = mail or 7
> >>> mail
> 7
>
> >>> mail = None
> >>> mail = 7 or mail
> >>> mail
> 7
>
> Here no matter the order iam writing the comparison it always return
> the number.
>
> why not the same here?
>
> >>> mail = None
> >>> mail = mail or ''
> >>> mail
> ''
>
> >>> mail = None
> >>> mail = '' or mail
> >>> mail
> >>>
>
> Why the or operator behaves differently with numbers than from
> strings?
>
> Please explain to me how it parses it with words.
>
> Thank you.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110406/bac2401c/attachment.html>


More information about the Python-list mailing list