Python

  1. Home
  2. Computing & Technology
  3. Python

Part 2: Getting Feed Information From the Data File With Python

From Al Lukaszewski, for About.com

2 of 9

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. Note that, if you use the CGI version of the RSS Reader, the bang line will need to read as follows (without quotes): '#!/usr/bin/python'. CGI requires the interpreter to be called directly.

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

Explore Python

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Python

  1. Home
  2. Computing & Technology
  3. Python

©2009 About.com, a part of The New York Times Company.

All rights reserved.