[Python-ideas] Before and after the colon in funciton defs.
ncoghlan at gmail.com
Fri Sep 23 05:45:00 CEST 2011
On Fri, Sep 23, 2011 at 1:26 PM, Steven D'Aprano <steve at pearwood.info> wrote:
> In this case, I believe that most of the work that needs to be done --
> making a copy of the function and code object -- are not magic. They are
> fully supported in standard Python. The only "magic" is manipulating the
> bytecode of the code object to that it turns some globals into locals.
That may be the core of the confusion here. Bytecode hacking is NOT
supported in standard Python. The language definition pretty much
stops at "function objects have a __code__ attribute that refers to
the immutable code object defining the algorithm they execute when
called". Anything below that point is implementation dependent (hence
the disclaimer on the output of the 'dis' module).
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-ideas