Python Best Practice: the Bang Line
Unless we want to call this application with a particular version of Python (i.e., 2.4 or 2.5), we need to begin the program with the "bang" line, telling the computer where to find Python. So make this or something similar the first line of the program:
#!/usr/bin/env python
I am working on a Linux system (most web servers are Apache on Unix/Linux) and therefore use that file structure. The command 'env' invokes an execution environment according to the argument you give it; here it is 'python', and the first Python interpreter in your execution path will be used.
Depending on your server's setup, you may at times want to tweak this so a different Python interpreter is called. For example, if we use Python 2.5's new 'with' statement but Python 2.5 is not the first interpreter in our path, we will need to specify that Python 2.5 is to be used. We would do this by changing the above line as follows:
#!/usr/local/bin/python2.5
- This is NOT the Beginning
- Python Best Practice: the Bang Line
- The Tasks This Python Program Must Do
- Holding the User Data in Python With CGI
- Holding the User Data in Python With PHP
- Defining the First Python Function
- Reading the RSS Feed as a Python File Object
- Using a Python Iterator
- Calling Python's Function, Retrieving the Feed Address
