Function that enters a line at the beginning of a file?

Heiko Wolf heiko.wolf at dlr.de
Tue Jan 15 10:34:08 EST 2002


Hi,

I've written a python script that does something like that:


#! /usr/bin/python

import os
os.system("/usr/bin/python script_file") #call python with script_file
as input


the script file shall use some user_defined commands that are defined
in a module my_module.py.
Now I want to open script_file and shift the whole text one line down,
and enter in the top line "import my_module", so that the commands are
available without having to enter the import-line myself.

Is there a python-function that does this?

Cheers,
Heiko Wolf



More information about the Python-list mailing list