[Python-ideas] Statement local functions and classes (aka PEP 3150 is dead, say 'Hi!' to PEP 403)
Paul Moore
p.f.moore at gmail.com
Mon Oct 17 15:00:06 CEST 2011
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...
Paul.
More information about the Python-ideas
mailing list