FileObjectの罠
2008-10-31 - ⧖ 1.0 min罠ではないと思いますが、久々にPythonではまる。
import commands
target = \
"""
#include <stdio.h>
struct ss {
int a;
int b;
char c;
};
int main(void)
{
struct ss s;
printf("%d\\n", sizeof(s));
}
"""
target_file = "dummmmmmmy.c"
fo = open (target_file , "w" )
fo .write (target )
print commands .getstatusoutput ("gcc %s" % (target_file ))
print commands .getstatusoutput ("./a.out" )
commandsモジュールでgcc実行しようとするとエラーになる。