On 4 November 2015 at 03:39, Steven D'Aprano
<steve+comp.lang.pyt...@pearwood.info> wrote:
>
> Better would be this:
>
> def chomp(lines):
>     for line in lines:
>         yield line.rstrip()  # remove all trailing whitespace
>
>
> with open(...) as f:
>     for line in chomp(f): ...

with open(...) as f:
    for line in map(str.rstrip, f): ...

--
Oscar
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to