There must be a better way

Colin J. Williams cjw at ncf.ca
Sat Apr 20 19:46:07 EDT 2013


Below is part of a script which shows the changes made to permit the 
script to run on either Python 2.7 or Python 3.2.

I was surprised to see that the CSV next method is no longer available.

Suggestions welcome.

Colin W.


def main():
     global inData, inFile
     if ver == '2':
        headerLine= inData.next()
     else:  # Python version 3.3
         inFile.close()
         inFile= open('Don Wall April 18 2013.csv', 'r', newline= '')
         inData= csv.reader(inFile)
         headerLine= inData.__next__()



More information about the Python-list mailing list