[Python-ideas] ('blue', 'red', 'orange' if something, 'green')
Westley Martínez
anikom15 at gmail.com
Sat Apr 23 21:36:06 CEST 2011
On Fri, Apr 22, 2011 at 07:41:11PM +0200, Sturla Molden wrote:
> Den 22.04.2011 11:59, skrev cool-RR:
> >Here's an idea that would have helped me today while coding. Allow
> >something like this:
> >
> > ('blue', 'red', 'orange' if some_condition, 'green')
> >
> >So 'orange' is included in the tuple only if `some_condition`
> >evaluates to `True`.
>
> This means it should be legal to write
>
> a = 'orange' if cond
>
> which presumably should mean
>
> if cond: a = 'orange'
>
> It retains some symmetry with
>
> a = 'orange' if cond else 'yellow'
>
> Sturla
>
>
>
>
>
>
>
>
>
>
No. This is a horrible idea.
More information about the Python-ideas
mailing list