def main():
range_dur = 0
xrange_dur = 0
def do_range():
start = time.time()
for i in range(2,10):
print i
range_dur += time.time() - start <---- cant see
def do_xrange():
start = time.time()
for i in xrange(2,10):
print i
xrange_dur += time.time() - start <---- cant see
do_range()
do_xrange()
print range_dur
print xrange_dur
if __name__ == '__main__':
main()
I know I could put range_dur
and xrange_dur
outside of main() and have them called global inside do_range()
and do_xrange()
to be seen but how come the above doesnt work?
Whats the inner-working of variable visibility for python?
or is there another solution besides using it as global?
return
value.