Library and real path name
michele.petrazzo at TOGLIunipex.it
Tue Aug 23 12:51:23 CEST 2005
Fredrik Lundh wrote:
> Michele Petrazzo wrote:
>>I want to redistribute the library that I create.
>>I create a project, its setup.py that when launched copy all files into
>>the "site-packages/library" directory. And here it's all ok.
>>When I call my library with:
>>I want that my library know where are its real path
> you can use the __file__ or __path__ variables to determine this.
> # get this module's directory
> import os
> prefix = os.path.dirname(__file__)
> or, inside a package __init__.py file:
> # get package's main directory
> prefix = __path__
More information about the Python-list