[Python-ideas] Tweaking closures and lexical scoping to include the function being defined

Arnaud Delobelle arnodel at gmail.com
Wed Sep 28 13:19:44 CEST 2011

On 28 September 2011 11:42, Steven D'Aprano <steve at pearwood.info> wrote:
> Paul Moore wrote:
>> Between these points and Arnaud Delobelle's point that code inside a
>> function should do nothing when the def itself is executed, I'm
>> getting more convinced that objects with persistent local scope should
>> be introduced *outside* the function body.
> I don't think having code inside a function execute is any worse than having
> code inside a class execute.

You can't compare the two. When a class statement is executed, the
*whole* of its body is executed; when a def statement is executed,
*none* of its body is.


More information about the Python-ideas mailing list