A question about readability
Marco
name.surname at gmail.com
Fri Dec 7 08:46:03 EST 2012
Hi all, do you think this code:
$ more myscript.py
for line in open('data.txt'):
result = sum(int(data) for data in line.split(';'))
print(result)
that sums the elements of the lines of this file:
$ more data.txt
30;44;99;88
11;17;16;50
33;91;77;15
$ python3.3 myscript.py
261
94
216
is explicit enough? Do you prefer a clearer solution?
Thanks in advance, Marco
--
Marco
More information about the Python-list
mailing list