as described in the previous section
works because the string representation of a
is the name of the file.
If you want to do something other than
print the name of the file,
you can fetch it by using the builtin Python
For example, if you want to use the Python
to figure out whether a file
exists while the
is being read and executed,
you can fetch the string as follows:
import os.path program_list = Program('hello.c') program_name = str(program_list) if not os.path.exists(program_name): print program_name, "does not exist!"
Which executes as follows on a POSIX system:
scons -Qhello does not exist! cc -o hello.o -c hello.c cc -o hello hello.o