Other difference with Perl: Python scripts in a pipe

Ian Kelly ian.g.kelly at gmail.com
Thu Mar 10 16:46:50 EST 2016


On Thu, Mar 10, 2016 at 2:33 PM, Fillmore <fillmore_remove at hotmail.com> wrote:
>
> when I put a Python script in pipe with other commands, it will refuse to
> let go silently. Any way I can avoid this?

What is your script doing? I don't see this problem.

ikelly at queso:~ $ cat somescript.py
import sys

for i in range(20):
    sys.stdout.write('line %d\n' % i)
ikelly at queso:~ $ python somescript.py | head -5
line 0
line 1
line 2
line 3
line 4
ikelly at queso:~ $ python3 somescript.py | head -5
line 0
line 1
line 2
line 3
line 4



More information about the Python-list mailing list