Scope confusion in Python REPL
Anssi Saari
as at sci.fi
Thu Jan 13 05:08:33 EST 2022
I ran into what seems odd scoping to me when playing with some matching
examples for 3.10.
I kinda thought that if I do from foo import * and from bar import * in
the Python REPL, I'd get everything from foo and bar in the main
scope. Or whatever the scope is at the prompt.
And yet, if I define function foo in module foo and function bar in
module bar and import as above, I can't call function bar from function
foo. But if I define functions foo and bar at the prompt, then I can. So
what's the difference in scoping here?
More information about the Python-list
mailing list