[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:
- passing the needed values as args to the functions
- wrapping the functions as methods of a class, passing the whole state 
as args to the class initializer.



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to