Having a module ask itself where it's at.
Lee Harr
missive at frontiernet.net
Sat Feb 15 21:55:26 EST 2003
In article <bdb5b58f.0302151327.702fe17f at posting.google.com>, logistix wrote:
> I'm trying to bundle a ConfigParser file with a package I'm working
> on. How can I have the module in the package locate this file?
>
> Since it's being loaded via import, and directory could really be the
> current working directory when the script is executed.
>
> Any pointers would be appreciated.
One way is to put the file in the directory with the module.
20:49 >python
Python 2.2 (#1, Jan 23 2002, 06:46:11)
[GCC 2.95.3 20010315 (release) [FreeBSD]] on freebsd4
Type "help", "copyright", "credits" or "license" for more information.
>>> import random
>>> random.__file__
'/usr/local/lib/python2.2/random.pyc'
>>>
More information about the Python-list
mailing list