Defending the ternary operator

Anders Hammarquist iko at cd.chalmers.se
Wed Feb 12 09:08:16 EST 2003


In article <7xk7g62pxz.fsf at ruckus.brouhaha.com>,
Paul Rubin  <http://phr.cx@NOSPAM.invalid> wrote:
>iko at cd.chalmers.se (Anders Hammarquist) writes:
>> Also, using it forced me to learn the Pythonic meaning of
>> and and or, and so I do not find constructs such as
>> "spam = eggs and eggs.count()" at all strange. So, in the end,
>> I think I now write better and more beautiful code as a result
>> of being forced to abstract away the ternary.
>
>The other interpretation is that Python's lack of conditional
>expressions warped your sense of beauty until you found it natural to
>write ugly constructs like that ;-).

Yes, there is that interpretation too ;-). Though in my defense
I have to say that I tend to avoid the "and" constructs, as
they don't sit quite right. "or" constructs, however, I have
no qualms about. "foo = spam or eggs" is quite clear I think.

/Anders

-- 
 -- Of course I'm crazy, but that doesn't mean I'm wrong.
Anders Hammarquist                                  | iko at cd.chalmers.se
Physics student, Chalmers University of Technology, | Hem: +46 31 88 48 50
G|teborg, Sweden.           RADIO: SM6XMM and N2JGL | Mob: +46 707 27 86 87




More information about the Python-list mailing list