Re: How do functions get access to builtins?

2013-01-24 Thread Steven D'Aprano
Rouslan Korneychuk wrote: I found the answer in Python's source code. When you execute a code object, PyFrame_New is called which gets 'bultins' from 'globals', but inside PyFrame_New (defined on line 596 of Objects/frameobject.c) is the following (line 613): builtins =

Re: How do functions get access to builtins?

2013-01-20 Thread Rouslan Korneychuk
On 01/19/2013 09:59 PM, Steven D'Aprano wrote: I've been playing around with ChainedMap in Python 3.3, and run into something which perplexes me. Let's start with an ordinary function that accesses one global and one builtin. x = 42 def f(): print(x) If you call f(), it works as

How do functions get access to builtins?

2013-01-19 Thread Steven D'Aprano
I've been playing around with ChainedMap in Python 3.3, and run into something which perplexes me. Let's start with an ordinary function that accesses one global and one builtin. x = 42 def f(): print(x) If you call f(), it works as expected. But let's make a version with no access to