[issue24800] exec docs should note that the no argument form in a local scope is really the two argument form

2021-03-07 Thread Eryk Sun
Eryk Sun added the comment: So there are a couple things to clarify here. When the documentation says "if the optional parts are omitted, the code is executed in the current scope", I think it should explicitly state that this is equivalent to calling exec(object, globals(), locals()). This

[issue24800] exec docs should note that the no argument form in a local scope is really the two argument form

2015-08-05 Thread R. David Murray
R. David Murray added the comment: OK, yes, so "a class body at global scope" or something like that :) LOAD_CLASSDEREF is another whole level of complication to the scoping weirdness for classes; see issue 19979 and issue 24129. -- ___ Python track

[issue24800] exec docs should note that the no argument form in a local scope is really the two argument form

2015-08-05 Thread eryksun
eryksun added the comment: > If exec gets two separate objects as globals and locals, > the code will be executed as if it were embedded in a > class definition. Probably there needs to be more clarification of the compilation context. Class definitions support lexical closures, whereas sourc

[issue24800] exec docs should note that the no argument form in a local scope is really the two argument form

2015-08-05 Thread R. David Murray
Changes by R. David Murray : -- versions: +Python 3.5, Python 3.6 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe

[issue24800] exec docs should note that the no argument form in a local scope is really the two argument form

2015-08-05 Thread R. David Murray
R. David Murray added the comment: OK, it looks like what the documentation of exec is missing is the fact that calling exec with no arguments in a non-global is equivalent to calling it with *two* arguments. That is, your "exec(script)" statement is equivalent to "exec(script, globals(), loc