Function for the path of the script?

Chris Angelico rosuav at gmail.com
Mon Oct 28 10:59:46 EDT 2013


On Tue, Oct 29, 2013 at 1:49 AM, Grant Edwards <invalid at invalid.invalid> wrote:
> On 2013-10-27, Chris Angelico <rosuav at gmail.com> wrote:
>> It's very common to want to know what directory you're in - it's a
>> good way to find data files.
>
> From a Unix point of view, that's also very wrong.  Data files don't
> belong in the same directory as the executable.

For installed programs, maybe; but we run a lot of scripts out of
source control, like a sanity checker that gets run immediately before
a commit. Some of them need data files that are also source-managed,
so we have them in the same directory. Locating those files is usually
easiest done by tailing onto the script's path.

ChrisA



More information about the Python-list mailing list