question of style
Paul Rubin
http
Sun Jul 5 02:17:21 EDT 2009
Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> 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."
I'd put it under the general rubric of "explicit is better than
implicit". The language shouldn't do silly automatic typecasts all
over the place. Yes, it saves a few keystrokes to say "if x:" instead
of "if len(x)==0:" or even "if bool(x):", but if I program in a style
where I like to think I know the type of something when I use it, I'd
like the interpreter to let me know when I'm wrong instead of
proceeding silently.
More information about the Python-list
mailing list