views:

82

answers:

2

I had always assumed that the first entry in sys.path by default was the current working directory. But as it turns out, on my system the first entry is the path on which the script resides. So if I'm executing a script that's in /usr/bin from /some/directory, the first entry in sys.path is /usr/bin. Is something misconfigured on my system, or is this the expected behavior?

+4  A: 

This is by design:

As initialized upon program startup, the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter.

source: http://docs.python.org/library/sys.html#sys.path

Yuval A
+1  A: 

You can get the current directory with os.getcwd().

Ned Batchelder
I understand that. I was just somewhat dumbfounded when celery wasn't able to find the celeryconfig file in the current directory. :-)
Jason Baker