namespace in Python?

Heiko Wundram modelnine at bit-bukket.org
Mon Dec 12 14:46:35 EST 2005


Carl wrote:
> What is the equivalent of a C++ (or C#) namespace in Python?

Your best bet will be modules:

---

a.py
====

def test():
    print "I am test() from a.py"

b.py
====

import a

a.test()

---

They are no direct match to C++-namespaces though, as the namespace doesn't
show up in the source but rather relies on the naming of the source
files...

--- Heiko.



More information about the Python-list mailing list