don't understand popen2

Donn Cave donn at drizzle.com
Thu Mar 23 05:52:19 CET 2006


Quoth gry at ll.mit.edu:
| Martin P. Hellwig wrote:
...
|> import popen2
|>
|> std_out, std_in = popen2.popen2("testia.py")
|>
|> x=std_out.readline()
|> print(x)
|>
|> std_in.writelines("notgood")
|>
|> x=std_out.readline()
|> print(x)
...
|> Traceback (most recent call last):
|>    File "F:\coding\pwSync\popen_test\popen_test.py", line 8, in ?
|>      std_in.writelines("notgood")
|> IOError: [Errno 22] Invalid argument
|>  >>>
...

| You gave it a single string, not a list(sequence) of strings.  Try
| something like:
|     std_in.writelines(["notgood"])

Did you try it?  For me, writelines(string) works fine.  Since in
Python, a string is in a sense a sequence of strings, this doesn't
even really contradict the documentation -

| ... The sequence can be any iterable object producing strings.

Anyway, it seems unlikely he would get that INVARG error for this
reason.  That's an error from the host operating system, not the
interpreter, and it mostly likely refers to the file descriptor.
Since it works for me, I guess his problem is basically this:

|> (python 2.4 + win32 extensions on XPProSP2)

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list