running python 2 vs 3

Steven D'Aprano steve+comp.lang.python at pearwood.info
Fri Mar 21 04:16:16 CET 2014


On Thu, 20 Mar 2014 21:06:24 -0400, Ned Batchelder wrote:

> In the #python IRC channel, there's a steady flow of people who run
> programs they find online, and they get a syntax error on "print", and
> we say, "Arch?" and they say, "yup".

When you install random programs you find online without going through 
your package manager, you have no guarantee that all the dependencies 
will be met. Particularly of third-party libraries, but also of standard 
Python libraries too:

http://bytes.com/topic/python/answers/448757-how-enable-rotor-python-2-4-2-a

If your script uses xreadlines, rotor, or mpz, using "python" to refer to 
both pre-2.4 and post-2.4 will cause breakage. Likewise, I've seen Python 
2.6 break applications because it removed string exceptions. So I'm not 
seeing anything out of the ordinary with Arch: any version change has the 
possibility to break scripts. Python 3 is just more obvious because of 
the change to print, which I daresay is a little more common than rotor...

Arch happens to be at the bleeding edge of that, bless them, but if you 
use Arch, that's what you're letting yourself into. You know what they 
say -- even Slackware users think Arch users are nuts :-)

I've also seen scripts broken because the script used a hard-coded path 
to the Python executable, like /usr/bin/python or /usr/local/bin/python. Or 
because they've hard-coded the version number. Or because they didn't 
hard-code the version number. I haven't seen scripts broken because "env" 
has moved, but I guess that's only a matter of time. Frankly, hash-bang 
lines are a dirty hack, and like all dirty hacks, they work really well 
until they suddenly don't. 



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/



More information about the Python-list mailing list