Advertisement
Lycanphoenix

Python 3 Backwards Compatibility Script (Alpha)

Jun 5th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. import sys
  2. """This wrapper is intended to reduce compatibility issues when running Python 3 code in Python 2. However, it is far from perfect. Either rewriting your code, or switching to a newer version of Python, is strongly recommended."""
  3.  
  4. if sys.version_info[0] != 2:
  5.     """Executes the following code if the user is running Python 3."""
  6.     def raw_input():
  7.         """This definition is included so that the version check below doesn't kill the program."""
  8.         return input()
  9.     def long():
  10.         return int()
  11.     def intern():
  12.         return sys.intern()
  13.  
  14. if sys.version_info[0] != 3:
  15.     """Executes the following code if the user is running Python 2."""
  16.     raw_input("Incompatible Python version detected. Please switch to Python 3.6 before running this program, or crashes may occur.")
  17.     def int():
  18.         return long()
  19.     #exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement