Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #2717
| Date | 2011-04-06 20:44 +0100 |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Subject | Re: TypeError: iterable argument required |
| References | <c5d42146-03fd-431d-982e-9d221faf4c91@glegroupsg2000goo.googlegroups.com> <0ad45930-e3aa-4ad9-a085-49a2d7ddaa1f@s3g2000vbf.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.83.1302119066.9059.python-list@python.org> (permalink) |
On 06/04/2011 20:21, Νικόλαος Κούρας wrote:
> On 6 Απρ, 19:58, "eryksun ()"<eryk...@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([])
False
>>> bool("Hello world!")
True
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: TypeError: iterable argument required "eryksun ()" <eryksun@gmail.com> - 2011-04-06 09:58 -0700
Re: TypeError: iterable argument required Νικόλαος Κούρας <nikos.kouras@gmail.com> - 2011-04-06 12:21 -0700
Re: TypeError: iterable argument required MRAB <python@mrabarnett.plus.com> - 2011-04-06 20:44 +0100
csiph-web