pure aesthetic question
Alex Martelli
aleax at aleax.it
Sun May 18 13:01:46 EDT 2003
<posted & mailed>
Helmut Jarausch wrote:
> as far as I know I have to put a Python script
> into a file with suffix '.py' (e.g. BackUp.py)
> and if it gets compiled there is a BackUp.pyc or
> BackUp.pyo file.
This is a must only for source files you want to
import as modules (indeed the compilation only
happens for such modules).
> Is it possible (under Linux) to get the plain name
> BackUp
> which executes the compiled and/or optimized script
> when invoked by the shell (system)
Sure! Put the textfile named BackUp on some directory
on your $PATH, chmod +rx it, and have as its first line:
#!/usr/local/bin/python
or whatever other path invokes your favourite Python -- a
popular choice is:
#!/usr/bin/env python
You can also have commandline switches on that line,
such as a trailing -O to tell Python to "optimize".
Alex
More information about the Python-list
mailing list