On Dec 10, 3:03 pm, Jean-Michel Pichavant
wrote:
> - Original Message -
> > On Dec 7, 6:46 pm, Marco wrote:
> > > 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(
- Original Message -
> On Dec 7, 6:46 pm, Marco wrote:
> > 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
On Dec 7, 6:46 pm, Marco wrote:
> 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;1
On Fri, 07 Dec 2012 14:46:03 +0100, Marco wrote:
> 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)
[...]
> is explicit enough? Do you prefer a clearer solution? Thanks in advance
In article ,
Marco wrote:
> 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 sum() line is a bit of a mouthful. I would refactor it into
something like this:
> for line