using globals
- From: sj.vanwerkhoven@xxxxxx
- Date: Thu, 03 Aug 2006 05:34:08 -0400
Hi,
I have got a problem with importing global variables. For instance I have
got two files:
# t1.py #t2.py
counter = 1
def counter_adder(filenr): def show_adder():
global counter import t1
counter+= 1 print("adder
is %d" % t1.counter)
if filenr == 1:
show_adder()
else:
import t2
t2.show_adder()
def show_adder():
print("adder is %d" % counter)
adder is 2counter_adder(1)
adder is 1counter_adder(2)
When I look at the outcome of two function calls I expected no differences
but much to my surprise it goes wrong when the global variable is imported.
It doesn't give the updated value but the value it get when instantiated.
Who come? What should I do to get the updated value
greetings,
Sjaak van Werkhoven
.
- Prev by Date: Re: Grammar parsing
- Next by Date: Re: Is there an obvious way to do this in python?
- Previous by thread: Grammar parsing
- Next by thread: Re: using globals
- Index(es):