I've written a small python script to create a file and calculate times. I've tested it on Fedora 10, and Ubuntu 8.x and it worked well. the python versions were 2.5.x.
I tried to run it on my production server (an old red hat based linux server), the version of python is 2.2.3. the script does not work and raises a syntax error in the class definition.
the script defines a class with methods to create files on disk an measure the time, to estimate disk write speed. it starts like this:
class TestDiskSpeed():
def __init__(self, rounds=1, speedMode=SPEED_MODE_MEGABYTE):
the class definition is pointed as the error by python 2.2.3.
what are the major changes in python since 2.2.3 that could possibly crash my application? I'm using these modules: os, sys, time, stat, gc.
Update:
by removing the ()
from class definition python accepted the class. but it raises another error on this line:
size = long(size) if size != None else self._size
I'm a PHP developer, just entered python programming (maybe a month), and am very used to the ternary operation which is done in PHP like this:
$var = (condition) ? $valueIfTrue : $valueIfFalse;
I searched and found it is done in python like the one I used for my size
variable. though it seems python 2.2.3 does not like it.
I was going to insert all the code in here (I'm going to release the script as LGPL anyway), but the code is more than 150 lines (still in development).