running python 2 vs 3

Mark H Harris harrismh777 at gmail.com
Thu Mar 20 17:11:28 CET 2014


On 3/20/14 9:58 AM, notbob wrote:

> I've installed python 3.3 on my Slack box, which by default comes with
> python 2.7.  I know how to fire up the different IDLE environments,
> but how do I differentiate between the scripts?

hi notbob, the two (or more) IDLE environments run very nicely 
side-by-side. If you access your scripts from the same directory (I do 
not) there really is no problem. The reason is that the .pyc files 
created for python2.x are only used by python2.  The .pyc files for 
python3.x are kept (by a naming convention) in __pycache__ , so there 
really is no problem.  Having said that, the only problem is that your 
script for python3 might not run in python2 (for various reasons) but 
the problem is not that the scripts are contained in the same folder.

I keep my python2 scripts in one folder ~/Documents/Python2/ and my 
python3 scripts in another one ~/Documents/Python3/

I add the two folders in the python paths browser (using site-packages) 
so that when I start IDLE for python2 it pulls its scripts from 
~/Documents/Python2/  and when I start IDLE for python3 it pulls its 
scripts from  ~/Documents/Python3/

There are *many* ways to organize this. Often I have to maintain two 
scripts (packages) one for each version. Although, I try to make my 
scripts run in both environments.  Often I have IDLE(2) ane IDLE(3) 
running and testing at the same time on the same box. This works very well.

marcus




More information about the Python-list mailing list