Telling python where to look for a script

Alex Martelli aleaxit at yahoo.com
Thu Jun 14 10:53:14 EDT 2001


"Brian Elmegaard" <brian at rk-speed-rugby.dk> wrote in message
news:3B289D8E.96908690 at rk-speed-rugby.dk...
>
>
> Alex Martelli wrote:
> >
> > the backslashes:-).  A module is meant to be imported.
> > A foo.py 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 bar.py on baz.dat
> being in . just by typing:
>
> c:\foo>python bar.py 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 site.py or sitecustomize.py (etc) would convince
python.exe to "search" for its bar.py 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.
    $  bar.py baz.dat
and their OS searches for executable bar.py 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"...:-).


Alex






More information about the Python-list mailing list