How two modules call functions defined in each other?
Reinhold Birkenfeld
reinhold-birkenfeld-nospam at wolke7.net
Sun Mar 20 05:31:36 EST 2005
Tian wrote:
> I am python beginner, I have a question about the interdependence of
> modules.
>
> For example, when I have two modules:
>
> module1.py
> -------------
> def plus(x):
> return add(x,1)
>
>
> module2.py
> -------------
> def add(x,y):
> return x+y
>
> def plus2(x):
> return plus(x)+1
>
>
> How should I write "import" in both files?
> What about the global varibals? is there anything like "extern" keyword
> in C?
> or python has some other solutions?
Yes. Either define plus and add in module1 or define each one in a
separate module.
Reinhold
More information about the Python-list
mailing list