Re: 2 inter-related questions

Guido van Rossum (Guido.van.Rossum@cwi.nl)
Sun, 05 Jul 1992 12:49:20 +0200

>Ok, since my python script requires argv[1], I have to call it from
>the shell, right ? There is not way from the python interpreter to go:
>
>>>> set shellProgramArgs = 'test2.c'
>>>> exec 'compilify'
>
>So that Python will issue compilify test2.c to the shell right ?

I have no idea what you want here -- it's totally un-Python syntax and
I don't know what 'compilify' is supposed to mean, but:

(a) a Python receives its arguments in sys.argv; you can interactively
import sys and assign anything you want to sys.argv.

(b) The 'os module defines an exec() function with the same
functionality as exec(2) in the C library.

(c) To run a Python script from an interactive Python interpreter, you
can either use the built-in function evalfile(), or (if the script's
file name ends in '.py') import it as a module. The first time you
import a module its statements are executed -- this initializes the
module. To re-run the statements in an imported module, use the
built-in function reload().

>( 2 )
>
>After I run a script from the shell , I sometimes would like to drop
>into the interpreter to see the values of some things . Is there a
>Python command to do this ?

No, but you can run the script from an interactive Python interpreter,
as explained above.

>See so basically what has happened is I cant use the python shell to
>test values after running a program and I also cant let a script
>running frm csh call the python shell after it has finished so I can
>examine values.

Again I don't know how to interpret your sentence, but maybe I've
answered it anyway?

>( 3 )
>
>os.popen execs its argument based on its own shell , not the one with
>my PATH environmental variable . As a result , it cant find things
>that are own my path that are not on the default PATH . Besides moving
>the executable to the current directory or another place on the
>default PATH, is there a workaround ?

Sounds like a problem in your C library -- on my system, popen
definitely sees my $PATH. Are you sure you are exporting $PATH from
your shell?

>Also : all of this is going into a FAQ sheet .

Is this a threat? :-)

--Guido van Rossum, CWI, Amsterdam <guido@cwi.nl>
"Kemal Ataturk had an entire menagerie called Abdul."