The ternary operator: more than one way to do it?

Michael Chermside mcherm at mcherm.com
Tue Mar 25 09:37:39 EST 2003


Erik Max Francis writes:
> Any language feature can be abused.  The writer of the abuse is to blame
> for such misuses, not the language.

Thomas Wouters responds:
> Then why is Python any better than C, C++, Java, Perl, *LISP, etc ? Why are
> we using indentation for blocks, if we can trust the writer not to mis-use
> indentation ? Many people will answer to the first by explaining Python is
> small, simple, easy to learn. Some may say (as they have in the past) 'it
> fits your brain'. Where does adding features from other languages stop ?

I think you're missing the point. Erik said that the fact that a language
feature can be abused is not necessarily a flaw in the feature. He didn't
say that no feature is ever useful. For instance, the basic if *statement*
can be abused by nesting if's dozens of levels deep so you can't easily
tell which if lines up with which else. But that doesn't make the if
statement a bad idea.

As for your example, you say "why are we using indentation for blocks if
we can trust the writer not to mis-use indentation?" The use of indentation
for blocks has little to do with programmers failing to line up thier
braces, it is there so coders and compilers will be using the SAME cues.

I understand your wish to have Python "fit your brain" -- and we all have
different brain sizes and shapes. For me, a feature like metaclasses gives
me lots of difficulty, distinguishing between __slots__ and __dict__ is
a major problem, but adding another expression form like conditional
expressions hardly makes a difference. Not that I'd give up metaclasses
(they're powerful enough to be worth it (I think)), but not all features
add equally to the "mental size" of a language.

-- Michael Chermside





More information about the Python-list mailing list