stuck at this from so much time,need help....please ..

Chris Angelico rosuav at gmail.com
Sat Nov 23 17:41:30 EST 2013


On Sun, Nov 24, 2013 at 9:33 AM, Bhanu Karthik
<bhanukarthik2002 at gmail.com> wrote:
> this is exact code..
> it is not even entering the if ...
> I tried ( c= (data is '/quit')if c)
>
> when i print c ,its printing false....I dont understand what is happening...please help..

Again, please get off Google Groups. Have a look at how your posts come out:

https://mail.python.org/pipermail/python-list/2013-November/661005.html

Note how your quoted text is double-spaced. This is one of the most
obvious and obnoxious problems, though not the only one.

You have two problems here. Firstly, comparing strings with 'is' is
wrong in most cases[1], so stick with ==. And secondly, my crystal
ball says that you're typing "/quit" and pressing enter, so your
socket read will be "/quit\r\n" or "/quit\n". To properly handle this,
you'll need to buffer and split as I was describing.

ChrisA



More information about the Python-list mailing list