how to call shell?

Tim Roberts timr at probo.com
Tue Feb 12 00:43:38 EST 2013


contro opinion <contropinion at gmail.com> wrote:
>
>>>> import os
>>>> os.system("i=3")
>0
>>>> os.system("echo $i")
>
>0
>>>>
>why i can't get the value of i ?

Each invocation of os.system creates a brand new shell that starts, runs,
and terminates.  Your first command adds a variable "i" to the environment
for that shell, but the variable is deleted when the shell procsess
terminates.
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list