Library and real path name
Michele Petrazzo
michele.petrazzo at TOGLIunipex.it
Tue Aug 23 06:51:23 EDT 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:
>>
>>import library
>>library.class()
>>
>>I want that my library know where are its real path
>>(site-packages/library/)
>
>
> you can use the __file__ or __path__ variables to determine this.
> e.g.
>
> # 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__[0]
>
> </F>
>
>
>
Thanks,
it work
Michele
More information about the Python-list
mailing list