Some example lines to add to any test code you write that work from Python 1.4.0 to 3.2.2 on various platforms. It is all Public Domain and you can do with it as you please...
This is to go alongside this little snippet... http://code.activestate.com/recipes/577836-raw_input-for-all-versions-of-python/?in=lang-python
I really don't care how you vote and/or rate this as I try to write Python code for my usage to work on the platforms and versions inside the code.
Some people will know this but MANY won't and there will be more to come that involve platform and version compatibility...
Enjoy finding simple solutions to often VERY difficult problems...
(Watch out for wordwrapping, etc...)
Bazza, G0LCU...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | # compatibility.py
#
# Backwards compatibility for text mode Python 1.4.0 to 3.2.2...
# Some simple lines 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.
# These are to go along with this pointer...
# http://code.activestate.com/recipes/577836-raw_input-for-all-versions-of-python/?in=lang-python
# ===================================================================
# A method for generating a filename automatically and in this case
# adding an extension .DAT. The higher the number the "newer" the
# filename. Simple and easy to do.
import time
# Allocate default values.
autofilename="0000000000.DAT"
n=int(time.time())
# Now generate the automatic filename.
autofilename=str(n)
autofilename=autofilename+".DAT"
# Just print to the screen as proof of the working example.
print(autofilename)
# ===================================================================
# ===================================================================
# Some ASCII print statements that work for general usage...
# These all look the same on screen whatever the version or platform
# above. These print two newlines.
print("")
print('')
# These are a simple basic "ECHO sometext" command.
print("This method can be used thoughout as a basic ECHO to the screen.")
print('This method can be used thoughout as a basic ECHO to the screen.')
# Now a print statement that uses a variable called "texttest".
# The bell character assumes that the audio is enabled in all the
# platforms above, otherwise it is ignored...
texttest="\n\nSometext to print to the screen...\a\b\b Overwrite two of the full stops."
print(texttest)
texttest='Single quotes with escape characters.\rMaybe the start of this line will be overwritten, see the code... ;o)'
print(texttest)
# ===================================================================
# Regular expressions DO NOT work nor print statements/functions with
# variables inside.
# There will be more to come.
# Enjoy finding simple solutions to often very difficult problems.
|
Backwards compatibility and platform independence is not easy but I am working on it... ;o)