[Tutor] Re: communication between java and python?

Lee Harr missive at hotmail.com
Fri Jan 14 00:43:11 CET 2005


>I'm trying to communicate between Python and Java and using
>os.popen(). But thing dont work...The Java program reads strings from
>stdin and the python program just writes to stdout.
>
>-first call the java program using:
>                                     handlers = os.popen('java StdIn)
>
>-then:
>                                     handlers[0].write('string')
>-and:
>                                     return_value_from_java = 
>handlers[1].read()
>


>From the docs on popen:

"""
popen(command[, mode[, bufsize]])
Open a pipe to or from command. The return value is an open file
object connected to the pipe, which can be read or written
depending on whether mode is 'r' (default) or 'w'.
"""

So, I do not believe that you can both write to and read from
a file handle opened with popen.

Check the docs for popen2 and see if that does what you want.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



More information about the Tutor mailing list