Steven D'Aprano writes:

[- -]

> What is this truthiness abstraction? It is the difference between
> "something" and "nothing".
>
> Values which represent nothing, e.g.:
>
> - None
> - numeric zero: 0, 0.0, 0j, Decimal(0) etc
> - empty strings u'', ''
> - empty containers [], (), {} etc.
>
> are treated as falsey. And values that represent something, e.g.:

[- -]

What do you say about things like iterators and generators? I'd say they
are containers, but they count as true even when they are empty.

bool(x for x in [3,1] if x in [2,7]) # True
list(x for x in [3,1] if x in [2,7]) # []

I think the abstraction really leaks on these things.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to