[Tutor] put?

Alan Gauld alan.gauld at btinternet.com
Thu May 1 19:43:20 CEST 2008


"Ross Glover" <ross at ross.mayfirst.org> wrote

> Hi, I'm just learning python (as a first language) and I wrote this 
> little snippet (cribbed from a website).  I'm wondering what 'put' 
> is and how it's used.

Hmmm. It sounds like you may be jumping in too deep too soon.
Do you understand about files yet? Or variables?
Are you comfortable with the concepts of stdin asnd stdout?
If not you should probably stick to some of the more basic
material until you understand those ideas.

OTOH, if you are happy with those ideas:

>> word = raw_input("enter your word >>")
>> put, get=os.popen4("dict -d wn " + (word))
>> for lines in get.readlines():
>>     print lines

put and get are the return values from popen and correspond
to stdin and stdout for the OS command inside popen().

get is the output of the command so the for loop prints
the results of the command. Its a rather long-winded
example IMHO.

But it depends where you found it and what exactly it was 
illustrating!

HTH


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list