Posts: 4,647
Threads: 1,494
Joined: Sep 2016
May-27-2024, 04:03 AM
(This post was last modified: May-28-2024, 04:01 AM by buran.)
when i import function foo() from a module with 2 functions, foo() and bar():
from mymodule import foo
and foo() needs to call bar(), which namespace will it get it from? local? global?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
(May-27-2024, 05:32 AM)deanhystad Wrote: foo() in mymodule calls bar() in mymodule. Importing foo() doesn't change that.
so its neither. a separate namespace where mymodule was imported is used. is there a way (for
foo) to access
something else in that namespace?
mymodule.something_else
does not seem to work.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,647
Threads: 1,494
Joined: Sep 2016
May-28-2024, 12:31 AM
(This post was last modified: May-28-2024, 12:32 AM by Skaperen.)
...or does it make everything in
mymodule appear to foo()
as in foo()'s
local namespace? if this is true does it do the same for bar() during bar() being called?
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Posts: 4,795
Threads: 76
Joined: Jan 2018
(May-28-2024, 12:31 AM)Skaperen Wrote: ...or does it make everything in mymodule appear to foo() as in foo()'s local namespace? if this is true does it do the same for bar() during bar() being called?
This is very difficult to understand. Can you give a concrete example with files and code?
« We can solve any problem by introducing an extra level of indirection »