newbie question

Larry Bates lbates at swamisoft.com
Thu Apr 15 17:44:07 EDT 2004


sdata may have additional characters in it.  If so,
there is no way it will ever equal "kill".  You
might want something like:

if sdata.startswith("kill"): s.close()

assuming that kill will be at the front of the data
stream of 1024 characters.

Larry Bates
Syscon, Inc.

"jeff" <plastic"no-spam-pls"@xsintrk.net> wrote in message
news:Xns94CCA82D89C84plasticnospamplsxsin at 216.77.188.18...
> Krzysztof Stachlewski <stach at fr.USUN.pl> wrote in
> news:c5mtsl$dns$2 at absinth.dialog.net.pl:
>
> > jeff wrote:
> >
> >> ex:
> >>
> >> a = "text str"
> >> if a == "text str": print a
> >>
> >> why doesn't that work?  i couldn't find much help about variable
> >> types in the manual, does it need a property like a.text?
> >
> > It works - at least on my computer.
> > That is: it prints "text str" to the console.
> > What did you expect it to do?
> >
> ok this is the bit i'm working with, i'm tinkering with sockets.
> when the recieved text == kill, i want the socket to close.  actually, the
> example i posted worked for me too, but i don't understand why this
> doesn't.
>
> while 1:
> sdata = s.recv(1024)
> if not sdata: break
> if sdata == "kill": s.close()
> print "Recieved:", sdata





More information about the Python-list mailing list