I spend a lot of time flipping back and forth between Python 2.x and 3.x: I use different versions for different projects, talk to people about different versions, explore differences between the two, and paste the output of REPL sessions into chat windows. I also like to keep long-running REPL sessions. These two activities in combination became quite confusing, and I’d often forget which version I was using.
1 2 3 4 5 6
After the hundredth time I made this mistake, I decided to modify my prompt to make it always obvious which version was which, even in long-running REPL sessions. You can do this by creating a file to be run when Python starts up. Add this line to your
1 2 3 4
This makes it obvious when you’re about to slip up:
1 2 3
I’ve also add this line to
mystartupscript.py to bite the bullet and start using print as a function everywhere:
This has no effect in Python3.x, but will move 2.x to the new syntax.