Any python wizards?

Started by Mr_Mr_Mr, June 24, 2014, 04:08:46 AM

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Mr_Mr_Mr

I'm trying to find out how I can have python detect what directory the python file is in, but I just can't.

My code (Not really mine but it's just for an example):
import os

dirname = "C:\\Users\Derek\Desktop\Bob"
bob = os.listdir(dirname)
print(bob)


Basically what I'm wanting is for python to find out dirname on it's own when I move the .py file to a new directory (for example, if I move the python file to "C:\\Users\Derek\Desktop\Bob\Test" then I want it to automatically detect that.)

I'm using Miscellaneous operating system interfaces.

---><--- Click the monkey