Module/namespace question

Alex Martelli aleax at aleax.it
Sun Mar 23 05:56:45 EST 2003


Matthew wrote:

> Hi,
> 
> I'm working on a small aplication which allows various lexicons (stored
> in their own modules) to be snapped into a parser to extract varying
> information from files. As different users will be writing their own
> lexicons, I'm wondering about namespace conflicts when the same vaiable
> may be defined in differing ways. From my newbie experiments, this
> doen't seem to be an issue as the variable changes references as the
> different modules are imported. Are there any dangers in this approach?
> Any help/hints/examples would be greatly appreciated. Thanks, matthew.

A so-called "global variable" is in fact an attribute of the module
object where it lives.  So, if modules are distincts, there can be
no name conflict between "global variables" in each of them -- two
"global" variables with the same name in distinct modules are entirely
separate variables.


Alex





More information about the Python-list mailing list