module file

I

Imbaud Pierre

I am willing to retrieve the file an imported module came from;
module.__file__, or inspect.getfile(module) only gives me the
relative file name. How do I determine the path?
Its obviously possible from python: ipython displays the information
(interactively: *module?*).
Python 2.4 on Suse 9.3 (clueless, I guess)
 
R

Rob Wolfe

Imbaud Pierre said:
I am willing to retrieve the file an imported module came from;
module.__file__, or inspect.getfile(module) only gives me the
relative file name. How do I determine the path?
 
I

Imbaud Pierre

Imbaud Pierre a écrit :
I am willing to retrieve the file an imported module came from;
module.__file__, or inspect.getfile(module) only gives me the
relative file name. How do I determine the path?
Its obviously possible from python: ipython displays the information
(interactively: *module?*).
Python 2.4 on Suse 9.3 (clueless, I guess)
Apologies: module.__file__, or inspect.getfile(module) only *gave* me
the relative file name, because the module was found in the current
directory! Changing the current directory, and having the module be
found thru the path, changed the returned path to an absolute
directory!
Hence the simplest form at hand was used. Thank you, python!
 
G

Gabriel Genellina

Note that this works only if the current dir has not changed. So it's a good
idea to store the absolute path as early as possible (before the program
have a chance to change the current dir)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top