On Tue, Feb 12, 2013, at 12:12 AM, contro opinion wrote: > >>> import os > >>> os.system("i=3") > 0 > >>> os.system("echo $i") > > 0 > >>> > why i can't get the value of i ?
Whenever you call os.system, a new shell is created and the command is run, system() then waits for the command to complete. You don't see i because your two system() calls are in two different processes: python> import os python> os.system('echo $$') 24294 0 python> os.system('echo $$') 24295 0 However, ths (e.g.) would work: python> os.system('i=3; echo $i') 3 0 HTH, -a -- http://mail.python.org/mailman/listinfo/python-list