__init__.py, __path__ and packaging
Sandro Dentella
sandro at e-den.it
Fri May 5 03:59:09 EDT 2006
> Now, why you couldn't do "dbg.DBG = ..."? Very simple... "from
> module import *" doesn't give you a dbg /module/, it only gives you
> references to each piece inside the module.
really the reason why I wanted that should probably be solved in other
ways. I just wanted to split my dbg module in different files but load the
dbg module in one single operation:
dbg/
|-- __init__.py
|-- lib
|-- __init__.py
|-- debug.py
|-- gtk_dbg.py
and inside dbg/__init__.py I used "from dbg.debug import *" so that a single
'import dbg' could present me the module 'debug' (of course in this simple
case seems easier to put debug.py directly under dbg, but my main case is
a much more complex module, with a tree structure that reflects the
relation between modules that I want to hide to the end user).
But to summarize, if I use 'from my_module import *' there is no way to reach
directly 'my_module' and set a variable there?
Thanks again
sandro
*:-)
> I'm trying to fix the packaging of a very simple package, but some problem
> show me that I have not well understood
>
> the structure of my package (some debug functions) is as follows:
>
> python/
> `-- dbg/
> |-- __init__.py
> `-- lib
> |-- __init__.py
> |-- debug.py
> `-- gtk_dbg.py
>
>
> my sys.path includes 'python' and I wanted that the content of debug.py was
> simply included by: 'import dbg', so I wrote dbg/__init__.py as follows:
>
> import os
> Dir = os.path.dirname(__file__)
> __path__ = [os.path.join(Dir, 'lib')]
> from debug import *
>
>
--
Sandro Dentella *:-)
e-mail: sandro at e-den.it
http://www.tksql.org TkSQL Home page - My GPL work
More information about the Python-list
mailing list