# Compatibility5.py
#
# Backwards compatibility for text mode Python 1.4.0 to 3.2.2...
# Some simple things that work for all these versions on the
# classic AMIGA, E-UAE, PCLinuxOS 2009, Debian 6.0.0, Windows XP and
# Vista and WinUAE. Note, classic AMIGAs and derivatives only reach
# Python version 2.4.6. AROS goes to version 2.5.2.
# Python versions checked against, 1.4.0, 2.0.1, 2.4.2, 2.5.2, 2.6.1,
# 2.6.6, 2.7.2, 3.0.1, 3.1.3 and 3.2.2.
#
# Versions (1.4.0), 2.0.1 to 2.7.2 have these already so running this
# code just imports "sys" only and therefore no harm is done...
#
# (C)2011, B.Walker, G0LCU. Initially issued to LXF as Public Domain.
# Now on AMINET. You may do with the code as you please.
#
# Single old functions to make Python backwards compatible... ;o)
#
# To add to an existing Python 1.x.x, (3.x.x), run using Classic AMIGA OS, type:-
#
# >>> exec(open('DRIVE:path/to/file/Compatibility5.py').read())<RETURN/ENTER>
#
# And away you go...
#
# These are a little tongue in cheek so don't take them too seriously... ;o)
# However they are functional even if a little cumbersome these days...

# The only _DIRECT_ import required...
import sys

# For machines with Python Version 1.x.x on AMINET...
# For example, standard Classic AMIGA A1200HD with Python 1.4.0 installed.
# This will ONLY work between decimal values 0 to 255 inclusive.
if sys.version[0]=="1": unichr=chr

# For machines with Python Version 3.x.x...
# Future versions of AMIGA?
if sys.version[0]=="3":
	# This enables universal keyboard input for ALL versions of Python...
	raw_input=input
	# "xrange()" is back...
	xrange=range
	# "unichr()" is back...
	unichr=chr
	# These functions, deleted from Version 3.x.x, are now back too...
	def execfile(STRING_some_path_and_file, globals={}, locals={}):
		exec(open(STRING_some_path_and_file).read()) in globals, locals
	def reload(some_module):
		import imp
		imp.reload(some_module)
		return(some_module)
	def coerce(x,y):
		if str(type(x))=="<class 'float'>" or str(type(y))=="<class 'float'>":
			x=float(x)
			y=float(y)
		else:
			x=int(x)
			y=int(y)
		return(x,y)
# ===================================================================
# There MIGHT be more to follow, I haven't decided yet...
# Enjoy finding simple solutions to often very difficult problems... ;o)