[Python-ideas] Statement local functions and classes (aka PEP 3150 is dead, say 'Hi!' to PEP 403)
Eric Snow
ericsnowcurrently at gmail.com
Mon Oct 17 18:39:24 CEST 2011
On Mon, Oct 17, 2011 at 7:00 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> On 17 October 2011 13:05, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> For comprehensions, the parallel with the proposed given statement
>> would be almost exact:
>>
>> seq = [x*y for x in range(10) for y in range(5)]
>>
>> would map to:
>>
>> seq = _list_comp given _outermost_iter = range(10):
>> _list_comp = []
>> for x in _outermost_iter:
>> for y in range(5):
>> _list_comp.append(x*y)
>
> Whoa...
>
> NAME1 = EXPR1 given NAME2 = EXPR2:
> ASSIGNMENT
> FOR LOOP
>
> ????
>
> Surely that doesn't match the behaviour for "given" that you were
> suggesting? Even if I assume that having _outermost_iter = range(10)
> before the colon was a typo, having a for loop in the given suite
> scares me. I can see what it would mean in terms of pure
> code-rewriting semantics, but it doesn't match at all my intuition of
> what the term "given" would mean.
>
> I'd expect the given suite to only contain name-definition statements
> (assignments, function and class definitions). Anything else should be
> at least bad practice, if not out and out illegal...
It's the same as a class definition--where you can, but likely don't,
have for loops and the like. In the end it's just the resulting
namespace that matters.
-eric
>
> Paul.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
More information about the Python-ideas
mailing list