Re: How to design a class that will listen on stdin?

2020-05-23 Thread Dan Sommers


On Saturday, May 23, 2020, at 07:24 -0400, zljubi...@gmail.com wrote:

> I have to talk to outer system by stdin/stdout.
> Each line that comes to stdin should be processed and its result returned 
> back to stdout. Logging should go to stderr.
> 
> How to design a class that will listed to stdin and call required methods in 
> order to process the data?

I wouldn't put it into a class, but the core of it looks something like
this:

for line in sys.stdin:
result = process(line)
print(result)
if some_condition():
break

The details may be different, and there's likely more error handling in
production code, but that's the general idea.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to design a class that will listen on stdin?

2020-05-23 Thread Dieter Maurer
zljubi...@gmail.com wrote at 2020-5-23 04:24 -0700:
>I have to talk to outer system by stdin/stdout.
>Each line that comes to stdin should be processed and its result returned back 
>to stdout. Logging should go to stderr.
>
>How to design a class that will listed to stdin and call required methods in 
>order to process the data?

Start by reading the Python tutorial
("https://docs.python.org/3/tutorial/index.html#tutorial-index;),
especially section 7.
-- 
https://mail.python.org/mailman/listinfo/python-list


How to design a class that will listen on stdin?

2020-05-23 Thread zljubisic
Hi,

I have to talk to outer system by stdin/stdout.
Each line that comes to stdin should be processed and its result returned back 
to stdout. Logging should go to stderr.

How to design a class that will listed to stdin and call required methods in 
order to process the data?

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