[Python-Dev] Adding a conditional expression in Py3.0 (original) (raw)

Michael Hudson mwh at python.net
Wed Sep 21 20:30:43 CEST 2005


BJörn Lindqvist <bjourne at gmail.com> writes:

My problem with this syntax is that it can be hard to read:

return if self.arg is None then default else self.arg looks worryingly like return NAME NAME.NAME NAME NAME NAME NAME NAME NAME.NAME That can already be written in Python:

No it can't! Would you believe I had this exact conversation two and a half years ago? :)

return self.arg or default

Consider what happens if self.arg is 0, here.

Cheers, mwh

-- If I had wanted your website to make noise I would have licked my finger and rubbed it across the monitor. -- signature of "istartedi" on slashdot.org



More information about the Python-Dev mailing list