[CentralOH] Namespaces

Mark Erbaugh mark at microenh.com
Tue Oct 19 22:33:55 CEST 2010


Assume I have a objecy named obj in a module, module.py, in a package named package.

As I understand there are essentially three ways to access obj in a client module:

import package.module

then everywhere func is used, it must be called using package.module.obj

or

from package.module import obj

then everywhere obj is used, it can be called using just obj.

or

from package.module import *

again everywhere obj is used, it can be called using just obj, but I have read the cautions about using wild imports, so I'm discounting this option.

or

import package.module as pm

then everywhere obj is used, it can be called using pm.obj



What are the pros and cons and recommended best practices?


Thanks,
Mark



More information about the CentralOH mailing list