[Python-ideas] Where-statement (Proposal for function expressions)
Jan Kaliszewski
zuo at chopin.edu.pl
Thu Jul 16 18:51:15 CEST 2009
16-07-2009, 17:37 Daniel Stutzbach <daniel at stutzbachenterprises.com> wrote:
> On Thu, Jul 16, 2009 at 10:06 AM, Paul Moore <p.f.moore at gmail.com> wrote:
>
>> x[i] = 12 where:
>> i = some_complicated_expression()
>>
>> Was that deliberate? If so, could you explain why now, so that it's on
>> record for the legions of people who will ask after it's implemented?
>> :-)
>
> Because only the right-hand side is in the where-block's scope.
Yeah. But I believe it should be possible using global/nonlocal keywords,
e.g.:
x[i] = 12 where:
global i
i = some_complicated_expression()
I think that many rules that apply for functions should also apply for
where-blocks. (But obviously not all of them, e.g. return, yield and such
stuff don't make sense)
16-07-2009, 18:16 Chris Perkins <chrisperkins99 at gmail.com> wrote:
> Yes, I'm very interested to see what proportion of people find the
> top-down style more readable.
I think even for the same person it can strongly depend on particular
application. It'll be good for some things, and useless for other.
But it isn't a strong argument against the feature. IMHO it'll be
useful in many situations.
15-07-2009, 14:49 Daniel Stutzbach <daniel at stutzbachenterprises.com> wrote:
> How about the following as additional syntactic sugar for the common
> one-function case?
> x = blah(f) where def f(item):
> body_of_f
+1 from me also.
Cheers,
--
Jan Kaliszewski <zuo at chopin.edu.pl>
More information about the Python-ideas
mailing list