[Tutor] subprocess.Popen.communicate()[]

Isaac hyperneato at gmail.com
Thu Dec 28 10:20:54 CET 2006

Hello tutors!

I have the following in my PYTHONSTARTUP file

def clear():
    x = subprocess.Popen("clear").communicate(None)[0]
    return x

so that when I type:
at the prompt, my terminal screen clears and I get only my prompt at the top
of the screen.

without the index at the end of .communicate() I get a tuple '(None, None)'
before my prompt at the top of the cleared screen. If I call either x[0] or
x[1] the command will return a single None, which is not displayed in the
interpreter but if I leave off the index".communicate(None)"- so that it
returns both  stdout and sterr then
clear() will return a tuple which will be displayed by the interpreter.

Am in correct in my interpretation of the interpreter?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20061228/ea8e38b7/attachment.html 

More information about the Tutor mailing list