Personally I find the "x if y else z" syntax much more readable than the
ternary operator because it reads more like english and is more explicit.
I've always found "y ? x : z" a bit obscure (though I use it all the time to
save typing). I think Python's version is more readable for a newbie who
might be unfamiliar with either syntax; if you'd never programmed before you
could still guess what Python's ternary syntax did.


On 7 July 2011 12:16, Michael Sparks <[email protected]> wrote:

> On Jul 5, 10:28 am, Flo Ledermann <[email protected]> wrote:
> ..
> > What do you  guys prefer?
>
> I prefer an explicit if statement over the ternery operator in any
> language.
>
> > Did I overlook anything obvious?
>
> This is mainly because I prefer code to be clear at a glance to the
> maintainer. I view the and/or trick as being amongst the worst
> hackery. (ie looks clever, but bound to fail on an edge case when you
> least want it to)
>
> > Has this been discussed thousands of times?
>
> Naturally :-)
>
>
> Michael.
>
> --
> To post: [email protected]
> To unsubscribe: [email protected]
> Feeds: http://groups.google.com/group/python-north-west/feeds
> More options: http://groups.google.com/group/python-north-west
>

-- 
To post: [email protected]
To unsubscribe: [email protected]
Feeds: http://groups.google.com/group/python-north-west/feeds
More options: http://groups.google.com/group/python-north-west

Reply via email to