Telling python where to look for a script

Alex Martelli aleaxit at
Thu Jun 14 16:53:14 CEST 2001

"Brian Elmegaard" <brian at> wrote in message
news:3B289D8E.96908690 at
> Alex Martelli wrote:
> >
> > the backslashes:-).  A module is meant to be imported.
> > A file can be both, but adapting the path is
> > relevant to module-use only, NOT to script-use.  All
> > clear so far...?
> >
> No, I'm sorry.

Ah, good.

> Being in c:\foo I would like to be able to execute on baz.dat
> being in . just by typing:
> c:\foo>python baz.dat
> Then I need something path-related with scripts, don't I?

I think you need to build python.exe to work differently
than it does today.  I don't believe any amount of black
magic in or (etc) would convince
python.exe to "search" for its argument elsewhere
than in the current directory.

Such an alternate python.exe (it had better be named
differently I guess) might have value, but we don't
have one today.

I think the reason this is not perceived to be a problem
is that people who work on operating systems don't do
it that way.  They write, e.g.
    $ baz.dat
and their OS searches for executable in the PATH.

This works on all Unix variants, and on NT/2000 as well if
you tell CMD.EXE that .py is one of the extensions that
make a file executable (sorry, I forget the incantation
for the latter purpose:-).  It *doesn't* work on 95/98/&c,
but then I DID say "operating systems"...:-).


More information about the Python-list mailing list