FileObjectの罠
Posted on Fri, 31 Oct 2008 00:39:19 +0900
罠ではないと思いますが、久々に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実行しようとするとエラーになる。