Saturday, November 7, 2009

About my Python

As I'm sure you know, Python currently comes in two flavors, the 3 series and the older 2 series. As the Python website states:

Python 3.1.1 was released on August 17th, 2009.
Python 3.1 is a continuation of the work started by Python 3.0, the new backwards-incompatible series of Python.

Apple, on the other hand, includes a Python installation, and it is currently 2.6.1:
localhost:Desktop te$ python
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>


I run all of my examples using 2.6, though earlier versions should work. The fanciest thing I like to do is list comprehension. According to this PEP, it became part of the language with version 2.0. There are a lot of differences with 3.0 (summarized here), but the one I know will be an issue is the print statement, which has become a function. You'll need to edit my code to change print "x" to print("x"). I think that's probably about it.

There isn't a very good reason to use 2.6 except that I get confused having multiple Pythons around. I even had 3.0 installed to play with, but then got rid of it. This can't go on forever, but it's where I am right now.

Also I don't do the sha-bang #! thing. I just do python myscript.py from the command line.