question of style
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Jul 4 21:36:13 EDT 2009
On Sat, 04 Jul 2009 11:10:48 -0700, Paul Rubin wrote:
> Anyway, Python's overloading of bool(...) is yet another misfeature and
> although it's convenient, the "explicit is better than implicit"
> principle indicates to avoid that sort of trick.
"Overloading of bool()"?
I don't understand what that means -- you mean you dislike the ability to
overload __bool__ (__nonzero__ in older Pythons)? That seems strange.
Python allows you to overload __int__ and __str__ and __float__, why is
__bool__ a misfeature? If that's what you mean, then I'm perplexed.
Or do you mean that all Python objects are interpretable in a truth
context? If that's what you mean, then I'm not perplexed, I'm sure you're
utterly wrong. Certain people -- a tiny minority -- keep trying to argue
that the ability to say "if obj" for arbitrary objects is somehow a bad
thing, and their arguments seem to always boil down to:
"If you write code that assumes that only bools have a truth value, then
surprising things will happen because all objects have a truth value."
Well duh.
If you think you have a better reason for calling the truth value of
arbitrary objects a "misfeature", I'd like to hear it.
--
Steven
More information about the Python-list
mailing list