Ross Glover | 1 May 09:51 2008

put?

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.  I cannot seem to find much about it.

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

thanks,

ross

--

-- 
If you know what you're doing, you must not be 'doing' a dissertation.

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Kent Johnson | 1 May 11:49 2008
Picon

Re: put?

On Thu, May 1, 2008 at 3:51 AM, 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.  I cannot seem to find much about it.
>
>
> > 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 variables that receive the result of the call to
popen4(). The docs for popen4() are here:
http://docs.python.org/lib/os-newstreams.html#os-newstreams

It says popen4() "returns the file objects (child_stdin,
child_stdout_and_stderr)", so put is linked to stdin for the child
process.

Kent
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Kriti Satija | 1 May 15:00 2008
Picon

unsubscribtion

Please unsubscribe my membership from python tutorlist.

      Bring your gang together. Do your thing. Find your favourite Yahoo! group at http://in.promos.yahoo.com/groups/
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

shawn bright | 1 May 15:13 2008
Picon

Re: send and receive HTTP POST

Thanks, sorry i was late getting back to you, but gmail thought this
was spam. Go figure.
Anyway, SOAPpy is doing great. Thanks

shawn

On Wed, Apr 30, 2008 at 2:05 PM, Kent Johnson <kent37 <at> tds.net> wrote:
> >  POST /soap/SMS.asmx HTTP/1.1
>  >  Host: api.upsidewireless.com
>  >  Content-Type: text/xml; charset=utf-8
>  >  Content-Length: length
>  >  SOAPAction: "http://upsidewireless.com/webservice/sms/Send_Plain"
>
>  It looks like you need SOAPpy:
>  http://diveintopython.org/soap_web_services/
>
>  Kent
>
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Evans Anyokwu | 1 May 16:31 2008
Picon

Re: unsubscribtion

Kriti,

You can unsubscribe yourself without waiting for anyone to do it for you.

Follow this link http://mail.python.org/mailman/listinfo/tutor
Bye.

Evans
http://www.javawug.org


On Thu, May 1, 2008 at 2:00 PM, Kriti Satija <kriti_satija <at> yahoo.co.in> wrote:
Please unsubscribe my membership from python tutorlist.


     Bring your gang together. Do your thing. Find your favourite Yahoo! group at http://in.promos.yahoo.com/groups/
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
bob gailer | 1 May 16:34 2008
Picon

Re: unsubscribtion

Kriti Satija wrote:
> Please unsubscribe my membership from python tutorlist.
>
>   
Only you can do that. Visit http://mail.python.org/mailman/listinfo/tutor

--

-- 
Bob Gailer
919-636-4239 Chapel Hill, NC

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Alan Gauld | 1 May 19:43 2008

Re: put?


"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 

_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor

Marc Tompkins | 1 May 20:59 2008
Picon

Re: put?

On Thu, May 1, 2008 at 12:51 AM, Ross Glover <ross <at> ross.mayfirst.org> wrote:

put, get=os.popen4("dict -d wn " + (word))
Something that can be a little confusing at first (and I haven't seen anybody mention it yet, so I thought I'd chime in) is that you can assign multiple variables at the same time.  It can be a little jarring if you aren't used to it.  So far you've probably only run into single assignments:  x=5, dog=cat, etc.
In contrast, this line runs a command that returns two values, and assigns those values to two variables called "put" and "get". 
If you weren't aware that multiple assignments were possible (and that this is what they look like), then this is a very confusing line of code indeed.

<rant>
Also - no offense to whoever put up the code you're learning from, but those variable names were poorly chosen!  Since you're just starting out, you have the opportunity to learn good habits early.  Don't use verbs as variable names!  It is almost guaranteed to confuse the heck out of anybody who has to read your code later - maybe even yourself, if you don't look at it often. 
Variable naming conventions are a very contentious topic - you'll get fanatical supporters of "x" and "y", or Hungarian notation, or "VeryDescriptiveVariableName", or whatever, and I'm not going to make an endorsement... but I would make two hard and fast rules:
-  Don't use variable names that conflict with reserved words, e.g. don't create a list variable and name it "list". 
-  Don't use variable names that SOUND like they might conflict with reserved words - like "put" and "get".

</rant>
 
--
www.fsrtechnologies.com
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Brain Stormer | 1 May 23:04 2008
Picon

How to skip to next line in for loop

I have the following code:

f = open('file.txt',r)
for line in f.read():
     if line == "3":
           line.next
           print line
f.close()

The file.txt looks like
1
2
3
4
5

I would like the code to output "4"

but I don't know how to use the next.  Are there any other way?

Thanks



_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor
Kent Johnson | 1 May 23:15 2008
Picon

Re: How to skip to next line in for loop

On Thu, May 1, 2008 at 5:04 PM, Brain Stormer <brnstrmrs <at> gmail.com> wrote:
> I have the following code:
>
> f = open('file.txt',r)
> for line in f.read():
>      if line == "3":
>            line.next

Try
  f.next()

line is a string, it doesn't have a next() method. The file itself is
iterable and has next(). Don't forget the parentheses!

Kent

>            print line
> f.close()
>
> The file.txt looks like
> 1
>  2
> 3
> 4
> 5
>
> I would like the code to output "4"
>
> but I don't know how to use the next.  Are there any other way?
>
> Thanks
>
>
>
>
> _______________________________________________
>  Tutor maillist  -  Tutor <at> python.org
>  http://mail.python.org/mailman/listinfo/tutor
>
>
_______________________________________________
Tutor maillist  -  Tutor <at> python.org
http://mail.python.org/mailman/listinfo/tutor


Gmane