Package that imports with name of dependent package

Maric Michaud maric at aristote.info
Sat May 13 11:32:12 EDT 2006


Le Samedi 13 Mai 2006 16:05, David Pratt a écrit :
> I'd appreciate hearing of what I can do in an __init__ file or what
> other strategy could make this work. Many thanks.
you should leave the original package intact and patch it with new mehod and 
moddule; for example (A is the original package):
A/__init__.py
A/B/__init__.py
A/B/C.py
X/__init__.py
X/B/__init__.py
X/B/C.py

just write in X/__init__.py :
import A.B.C, B.C
A.B.C = B.C


and all "from A.B import C" following an import of X will return X.B.C. 

This is how we "monkeypatch" products in Zope.

-- 
_____________

Maric Michaud
_____________

Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097



More information about the Python-list mailing list