On 8 mrt, 10:36, Bruno Desthuilliers <bruno. [EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] a écrit : > > > Dear, > > > I have wrote a script and want to group some functions of the script > > in a separate modulo so that I can import the module in other scripts > > and use the same functions there.. > > > The problem is that the common functions need access to some global > > variables defined in the script. > > And now you find out why globals are bad... > > > Python uses different namespaces for > > different modules so I can't access the variables of the script in the > > module. > > > What is the best solution to solve this problem? > > There's no one-size-fits-all answer. Usual solutions include:
I was hoping for a one-size-fits-all answer. But it seems to be that it doesn't exists. I already know these solutions, but was hoping for a better one. > - passing the needed values as args to the functions There are to many arguments so this is not a preferred solutions > - wrapping the functions as methods of a class, passing the whole state > as args to the class initializer. I already considerate this one, but I don't like it because it is not correct in terms of the object-oriented concept. Because there are no other solutions I have to bury my bad feelings and use this solution. Thanks, Bart
-- http://mail.python.org/mailman/listinfo/python-list