Re: exercice python

Pàgina inicial

Reply to this message
Autor: jeanluc
Data:  
A: guilde
Assumpte: Re: exercice python
Bravo,
vachement plus performant. y'a pas photo.
pour ma part, j'ai avec ton code :
 prompt> time python python_v2.py
 real    0m14.004s
donc, sur mon PC (y'a kde et le reseau qui tourne),
ce remet quasi python au niveau de perl. kif kif


donc, faut programmer elegant, c'est plus rapide.


Le Mardi 08 Février 2005 23:52, Mickael Profeta a écrit :
> fileIn = open("in.txt", "r")
> fileOut = open("out.txt", "w")
>
> lineNum=-1
> for line in fileIn:
>         lineNum += 1                    
>         if( lineNum & 1 ):
>                 fileOut.write(lineChop + line)
>         else:
>                 lineChop=line[:-1]
>
> if( not lineNum & 1 ):
>     fileOut.write(lineChop + "\n")
>
> fileIn.close()
> fileOut.close()


--
Jean-Luc