[Python-Dev] Adding a conditional expression in Py3.0

Mark Russell mark.russell at redmoon.me.uk
Wed Sep 21 13:08:53 CEST 2005


On Wed, 2005-09-21 at 11:10, Michael Hudson wrote:
> 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
> 
> to me.

I think that requriing parens helps a lot with the list-of-names problem
- it nicely delimits the conditional expression for human readers:

      return (if self.arg is None then default else self.arg)

In particular it breaks up the misleading grouping "return if".

Mark Russell



More information about the Python-Dev mailing list