Re: Locals [was Re: unintuitive for-loop behavior]

2016-10-02 Thread Chris Angelico
On Mon, Oct 3, 2016 at 3:09 PM, Steven D'Aprano wrote: > But if it did, then just as in the similar situation in IronPython and Jython, > you would still need to convince the compiler to use LOAD_FAST or equivalent > in > order to see it. Hence: > > > x = y = 'global' > def example(): > local

Locals [was Re: unintuitive for-loop behavior]

2016-10-02 Thread Steven D'Aprano
On Monday 03 October 2016 12:42, Steve D'Aprano wrote: > Yes the local would have been created, but you wouldn't see it from an > ordinary lookup of name x. You would need to use > > locals()['x'] > > to see that it exists. For x to return it, you have to convince the compiler > to use LOAD_