-2

I have Python2.7 installed on my computer. Is there a way to see if the .py code I have will compile in Python3 short of installing Python3?

Bijan
  • 7,737
  • 18
  • 89
  • 149

2 Answers2

4

You can use this program: https://docs.python.org/2/library/2to3.html

It will convert your code form 2 to 3, or give you information about what needs to be changed.

Ryan Weinstein
  • 7,015
  • 4
  • 17
  • 23
0

Without knowing anything about your code or operating system, it's hard to say what would be best. If static analysis is the way you want to go, I would suggest taking a look at this to see if any differences jump out at you:

https://docs.python.org/3/whatsnew/3.0.html#common-stumbling-blocks

By the way, Python 2 and 3 can be installed simultaneously on the same machine without too much effort if you change your mind.

If you're running Linux: Running both python 2.6 and 3.1 on the same machine

If you're running Windows: How to install both Python 2.x and Python 3.x in Windows 7

Community
  • 1
  • 1
McGlothlin
  • 2,059
  • 1
  • 15
  • 28