[Tutor] Querying a module's package path?
warpcat at gmail.com
Wed Nov 11 02:12:02 CET 2009
Presume I have a package 'a' like this:
- /pystuff (added to sys.path)
- /a (start of my package)
to import module.py:
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? Printing __file__ inside of module.py is close:
But I just want '*a.b.module'*
I can search sys.path for paths, remove them from __file__, switch slashes
to dots, strip extensions, etc. But I've learned that there's usually
something easier in Python that I'm just missing. I thought maybe the
inspect module, but I didn't have any luck there, nor did my Google queries.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor