Some syntactic sugar proposals
Andreas Waldenburger
usenot at geekmail.INVALID
Wed Nov 17 10:24:33 EST 2010
On Wed, 17 Nov 2010 10:18:51 -0500 Mel <mwilson at the-wire.com> wrote:
> Christopher wrote:
>
> >> ? Of course we can write it as
> >> t = foo() if pred(foo()) else default_value
> >> but here we have 2 foo() calls instead of one. Why can't we write
> >> just something like this:
> >> t = foo() if pred(it) else default_value
> >> where "it" means "foo() value"?
> >
> > i don't like magic names. what about:
> >
> > t = foo() as v if pred(v) else default_value
>
> !! so: assignment inside an expression.
>
I like the idea of having an "as ... if" construct, though. :)
/W
--
To reach me via email, replace INVALID with the country code of my home
country. But if you spam me, I'll be one sour Kraut.
More information about the Python-list
mailing list