Compatibility with both Python 2(.7) and 3

This commit is contained in:
Joerg Rings
2014-05-19 11:23:53 -05:00
parent 991634a58e
commit 93d83ca077
12 changed files with 93 additions and 67 deletions

View File

@@ -24,7 +24,7 @@ def loadfmap( fname ):
return fmap, nmap
def write_nmap( fo, nmap ):
for i in xrange( len(nmap) ):
for i in range( len(nmap) ):
fo.write('%d\t%s\ti\n' % (i, nmap[i]) )
# start here
@@ -41,7 +41,7 @@ for l in open( 'agaricus-lepiota.data' ):
else:
assert arr[0] == 'e'
fo.write('0')
for i in xrange( 1,len(arr) ):
for i in range( 1,len(arr) ):
fo.write( ' %d:1' % fmap[i][arr[i].strip()] )
fo.write('\n')

View File

@@ -3,7 +3,7 @@ import sys
import random
if len(sys.argv) < 2:
print 'Usage:<filename> <k> [nfold = 5]'
print ('Usage:<filename> <k> [nfold = 5]')
exit(0)
random.seed( 10 )