os.system() << 8 ?

Jacek Generowicz jacek.generowicz at cern.ch
Wed May 28 10:53:31 EDT 2003


#include <cstdlib>

int main(int argc, char* argv[]) {
  return atoi(argv[1]);
}

Compiling the above to ./a.out, and calling it with the following
Python script

import os
for i in range(256):
    print i, os.system("./a.out " + `i`)


gives results that look like this:

0 0
1 256
2 512
3 768
4 1024
5 1280
6 1536
7 1792
8 2048

... and so on.

Why does os.system seem to return a value which is 256 times the actual
status code returned by its argument ?




More information about the Python-list mailing list