[Tutor] Querying a module's package path?

Lie Ryan lie.1296 at gmail.com
Wed Nov 11 08:15:13 CET 2009


Eric Pavey wrote:
> Presume I have a package 'a' like this:
> 
>     * /pystuff  (added to sys.path)
>           o /a  (start of my package)
>                 + __init__.py
>                 + /b  
>                       # __init__.py
>                       # module.py
> 
> to import module.py:
> import *a.b.module*
> 
> What I'm trying to find is a way to query exactly what I typed above (in 
> bold):  Inside of module.py, can it query it's path back to the package 
> root?  

Why would you want that? Can you describe the problem you're having now 
that requires you to know the module's package path? Right now, you're 
just describing a solution to your problem, not the problem itself. 
Maybe we can find another solution that doesn't involve knowing the 
module's package path.



More information about the Tutor mailing list