please help me understand os.system() result

Tim Roberts timr at probo.com
Thu May 22 01:42:06 EDT 2003


Roman Suzi <rnd at onego.ru> wrote:

>On Tue, 20 May 2003, Keisuke URAGO wrote:
>
>> You should shift 8bits like this.
>> 
>> >>> os.system("exit 7") >> 8
>> 7
>> >>> os.system("python -c 'import sys;sys.exit(1)'") >> 8
>> 1
>> >>> os.system("python -c 'import sys;sys.exit(2)'") >> 8
>> 2
>
>Thank you, I already guessed it.
>However, it's strange that os.system() behaves like this on Linux and the 
>other way on WinNT/2000. (This is in the docs - so ok)

It's not so strange; os.system is returning exactly what the "system"
standard library function would return.  Windows programmers are used to
their way, Unix programmers are used to their way.

For those few programs that need to work on both, it only takes a couple of
lines of code to handle this.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.




More information about the Python-list mailing list