Jun-13-2018, 03:18 AM
don't cheat and try to run these. the question applies to Python version 2 or 2.7 or 2.7.whatever. which of these works right (for a useful definition of "right"?
catlines1.py:
catlines1.py:
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import sys for line in sys.stdin: print('line =',repr(line)) sys.stdout.flush()catlines2.py:
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import sys while True: line=sys.stdin.readline() print('line =',repr(line)) sys.stdout.flush()if you are going to try these, try piping in the ping command like
[font=Courier New, Courier, monospace]ping -c 6 127.0.0.1|python2 catlines1.py[/font]
or ping -c 6 127.0.0.1|python2 catlines2.py
and see what happens. the -c 6
option for ping limits it to just 6 pings.
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.