What are modules really for?

Mike Meyer mwm at mired.org
Wed Aug 10 22:16:26 EDT 2005


Peter Hansen <peter at engcorp.com> writes:

> Dan wrote:
>> You might think of modules in Python as like packages in Java. However,
>> putting classes in the same module doesn't give them any additional
>> powers to interact with each other. (At least, not that I know of.)
>
> Use of "global" to rebind shared module-scope names...

You can rebind module-scope names from outside the module. It's an
ugly practice, and I wouldn't recommend it, but it *is* possible.

But you're on the right track. If two consenting classes want to share
_named module variables, it's best that they be in the same module.

       <mike
-- 
Mike Meyer <mwm at mired.org>			http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.



More information about the Python-list mailing list