Two curious errors when function globals are manipulated
Steven D'Aprano
steve at pearwood.info
Tue Jul 5 23:00:20 EDT 2016
On Wed, 6 Jul 2016 02:13 am, eryk sun wrote:
> On Tue, Jul 5, 2016 at 3:50 PM, Steven D'Aprano <steve at pearwood.info>
> wrote:
>> It works with exec:
[...]
> No, actually it doesn't work. Remember that when you store to a
> variable, it's implicitly a local variable, for which CPython uses
> STORE_NAME in unoptimized code. To test this properly you need to
> declare the variable as global, so that it uses STORE_GLOBAL:
/face-palm
Of course you're right, I knew that. Sorry for the noise.
--
Steven
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.
More information about the Python-list
mailing list