Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
python 2-3 compatibility and gotchas #451
Perhaps this has been previously discussed. It would be great to ensure that all code is compatible with python 2 and python 3. This ensures that the installation version does not hinder the learning. The syntax is similar enough that we should not take a purists' stance here.
There are simple things that may confuse instructors used to one version, but the students report a different output. It may be useful to add to the lessons as notes to instructors on some brief/potential gotchas:
I used to maintain a list of differences that beginners commonly run into, perhaps we can incorporate some of this: http://python.berkeley.edu/learn/
As far as I remember, we are supporting and teaching Python 3. We signed the Python 3 statement which says
As far as I remember, we are requiring/recommend learners to install Python 3 for more than a year. I expect that instructors teach using Python 3 (from their default installation or using a virtual environment) to avoid different output from the learners.
I think our lessons should be Python 2 compatible and Python 3 compatible.
For example, this
This can be mitigated easily with a
Encourage Python 3, but don't break Python 2 if we don't have to, and warn instructors about gotchas - this feels robust.
I disagree. When I learnt Fortran I hate that my instructor was enforcing our code to be Fortran 77 compatible.
Realistic, except for significant figures reasons, who does write
If a learner is using Python 2 for what ever reason, they should be aware of the differences between Python 2 and Python 3. Otherwise, we don't need to cover it.
This is the case of
I believe we should stick to teaching python 3. There are several reasons for this: