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

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


"Jason Orendorff" <jason at jorendorff.com> wrote in message
news:mailman.1011111801.11359.python-list at python.org...
    ...
> 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
...?


Alex







More information about the Python-list mailing list