Some source code
nnes
pruebauno at latinmail.com
Sun Feb 22 17:05:25 EST 2004
Adam Przybyla <adam at gliwice.pl> wrote in message news:<c1adgj$qgl$1 at atlantis.news.tpi.pl>...
> nnes <pruebauno at latinmail.com> wrote:
> > file('output.txt','w').writelines(['%s,"%s"\n' % (line[:-1],
> > sum(map(int,line[1:-2].split('","')))) for line in
> > file('input.txt')])
> file('output.txt','w').writelines(['%s,"%s"\n' %
> (line[:-1],sum(eval(line[1:-2]))) for line in file('input.txt')])
> Regards
> Adam Przybyla
You mean:
file('output.txt','w').writelines(['%s,"%s"\n' % (line[:-1],
sum(eval(line[1:-2].replace('"','')))) for line in file('input.txt')])
input.txt in the form of:
"1","2","3"
"4","5","6"
And both versions are exactly 132 bytes long. It is a draw :-P
More information about the Python-list
mailing list