how to get the path of a module (myself) ?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Jun 3 07:32:03 CEST 2009


En Tue, 02 Jun 2009 06:11:30 -0300, Vlastimil Brom
<vlastimil.brom at gmail.com> escribió:

> [...] just in case the main problem would be the
> use of __file__ ...
> It seems, that the exe files generated from py2exe don't recognise
> this variable;
> sometimes I used code like
>
> try:
>     __file__
> except NameError: # py2exe
>     __file__ = sys.path[0]

I think you meant __file__ = sys.argv[0]

> cf. e.g.  
> http://mail.python.org/pipermail/python-list/2001-May/085384.html

That's a rather old post. The "right" way to obtain a resource from a
package is using pkgutil.get_data(), and py2exe should support it by now.
(I haven't tested, but I think it does).
http://docs.python.org/library/pkgutil.html

-- 
Gabriel Genellina




More information about the Python-list mailing list