Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #34459
| From | Marco <name.surname@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | A question about readability |
| Date | 2012-12-07 14:46 +0100 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <k9srup$kc7$1@speranza.aioe.org> (permalink) |
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
A question about readability Marco <name.surname@gmail.com> - 2012-12-07 14:46 +0100 Re: A question about readability Roy Smith <roy@panix.com> - 2012-12-07 08:57 -0500 Re: A question about readability Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-12-07 14:10 +0000 Re: A question about readability rusi <rustompmody@gmail.com> - 2012-12-07 11:12 -0800
csiph-web