Carl Banks wrote:
On Apr 29, 6:46 am, Bruno Desthuilliers <bruno.
42.desthuilli...@websiteburo.invalid> wrote:
Filip Gruszczyński a écrit :
One of the Python Zen rules is Explicit is better implicit. And yet
it's ok to do:
if x:
do_sth
when x is string or list. Since it's very comfy, I've got nothing
against though. I am just curious, why is it so?
Because it is explicit (or at least considered as such) that in Python,
an empty list or string (as well as empty tuples, dicts and sets and
numeric zeros, False and None) have a false value in a boolean context.
I think a better answer to this question is: "The Zen of Python is not
called the Cold Hard Rules of Python"; in this case the language goes
against this particluar Zen as it does in many other places.
"Although practicality beats purity". It's all about balance.
--
http://mail.python.org/mailman/listinfo/python-list