[Tutor] global is bad but ...
Dinesh B Vadhia
dineshbvadhia at hotmail.com
Tue Nov 13 17:40:50 CET 2007
Consider a data structure (say, an array) that is operated on by a bunch of functions eg.
def function_A
global array_G
do stuff with array_G
return
def function_B
global array_G
do stuff with array_G
return
def function_C
global array_G
do stuff with array_G
return
The described way is to place the statement 'global' in line 1 of each function. On the other hand, wiser heads say that the use of 'global' is bad and that reworking the code into classes and objects is better.
What do you think and suggest?
Dinesh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20071113/9538cca9/attachment.htm
More information about the Tutor
mailing list