Getting module location

  • Thread starter Thomas Dybdahl Ahle
  • Start date
L

limodou

2006/1/5 said:
Is it possible for an imported module to find its own location?

you can access __file__(missing for built-in modules) or __path__(used
for a package) attribute to find a module's location.
 
T

Thomas Dybdahl Ahle

Den Thu, 05 Jan 2006 14:53:40 +0800. skrev limodou:
you can access __file__(missing for built-in modules) or __path__(used
for a package) attribute to find a module's location.

Super, what I needed seems to be os.chdir(os.path.dirname(__file__)).
Works flawlessly. Thank you.
 

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

Forum statistics

Threads
474,275
Messages
2,571,381
Members
48,070
Latest member
nick_tyson

Latest Threads

Top