input/output through socket or COM port

Chris Liechti cliechti at gmx.net
Sat Apr 27 21:10:07 EDT 2002


Jive Dadson <jdadson at ix.netcom.com> wrote in 
news:3CCB1CE9.3E08F027 at ix.netcom.com:
> I want to configure Python so it will read and write standard input and
> output to and from either a TCP/IP socket or a serial COM port data
> link. There will be no terminal or keyboard.

my serial lib migh be of interest for you http://pyserial.sf.net
 
> I compiled Python under VC++ and used the Visual Studio debugger to step
> through the code, but as yet I have not even been able to find where in
> the code Python does input/output!

just assign your own file like object to sys.stdin,stderr and stdout. you 
don't even need a compiler for that...

for out and err you only need the "write" method. 
don't know whats all needed for the stdin object. at least "readline". i'd 
provide "read" and "readlines" too.
you might need to overload "input" and "raw_input" in the builtins too.

when you receive code from an other machine you might be interested in the 
rexec module, if security is an issue.

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list