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

Alex Martelli aleax at
Tue Jan 15 12:32:17 EST 2002

"Jason Orendorff" <jason at> wrote in message
news:mailman.1011111801.11359.python-list at
> Maybe you want this.  It avoids using os.system() too, so it should
> be faster.  I hope it's self-explanatory.
>   #!/usr/bin/python
>   exec "import my_module"
>   execfile("script_file")

I think I must be missing something.  Why
    exec "import my_module"
rather than the plain good old
    import my_module


More information about the Python-list mailing list