Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

major changes in python since version 2.2.3

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).

like image 596
farzad Avatar asked Dec 08 '25 10:12

farzad


1 Answers

I wrote a script a while ago to help answer this exact question: pyqver.

This script attempts to identify the minimum version of Python that is required to execute a particular source file.

When developing Python scripts for distribution, it is desirable to identify which minimum version of the Python interpreter is required. pyqver attempts to answer this question using a simplistic analysis of the output of the Python compiler.

Use the -v option to list the reasons why your script requires a particular minimum version. This is very helpful in deciding what to change to make your script work with a specific version of Python.

As always, feel free to fork and contribute!

like image 194
Greg Hewgill Avatar answered Dec 10 '25 00:12

Greg Hewgill



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!