TypeError: iterable argument required

Blockheads Oi Oi breamoreboy at yahoo.co.uk
Wed Apr 6 12:12:29 EDT 2011


On 06/04/2011 16:57, Νικόλαος Κούρας wrote:
>>>> 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.

See this for an explanation of Python truth value testing.
http://docs.python.org/library/stdtypes.html

Cheers.

Mark L.




More information about the Python-list mailing list