Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
>  On Thu, 17 Aug 2006 17:16:25 +0000, [EMAIL PROTECTED] (Cameron Laird)
>  declaimed the following in comp.lang.python:
> 
> > Question:
> >   import subprocess, StringIO
> > 
> >   input = StringIO.StringIO("abcdefgh\nabc\n")
> 
>       Here you override the builtin function "input()"
> >       # I don't know of a compact, evocative, and
> >       # cross-platform way to exhibit this behavior.
> >       # For now, depend on cat(1).
> >   p = subprocess.Popen(["cat"], stdout = subprocess.PIPE, 
> >                             stdin = response)
> 
>       Here you specify the non-existant "response" 

Assume the OP meant to write this

>>> import subprocess, StringIO
>>> inp = StringIO.StringIO("abcdefgh\nabc\n")
>>> p = subprocess.Popen(["cat"], stdout = subprocess.PIPE, stdin = inp)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.4/subprocess.py", line 534, in __init__
    (p2cread, p2cwrite,
  File "/usr/lib/python2.4/subprocess.py", line 830, in _get_handles
    p2cread = stdin.fileno()
AttributeError: StringIO instance has no attribute 'fileno'
>>> 



-- 
Nick Craig-Wood <[EMAIL PROTECTED]> -- http://www.craig-wood.com/nick
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to