fully-qualified namespaces?

Lenny G. alengarbage at yahoo.com
Mon Sep 12 11:29:52 EDT 2005


Suppose I have a python module named Hippo.  In the Hippo module is a
class named Crypto.  The Crypto class wants to 'from Crypto.Hash import
SHA' which refers to the module/classes in python-crypto.  Other
classes in the Hippo module want to 'import Crypto' referring to
Hippo.Crypto.

How do I do this?  For now, I just renamed my Hippo.Crypto to
Hippo.HippoCrypto and everything is okay as long as I use 'HippoCrypto'
to refer to that class.  But, this is of course redundant.  What I
really want to do is use

'import Crypto'         # to refer to python-crypto
'import Hippo.Crypto'   # to refer to Hippo.Crypto

but the 2nd item doesn't seem to work from within the Hippo module.
What am I missing?

  Thanks,
  Lenny G.




More information about the Python-list mailing list