Here's a puzzle...

Erik Max Francis max at alcyone.com
Sun Jul 22 02:23:36 CEST 2001


TheDustbustr wrote:

> Unless my logic is flawed, this should return 'PRIVMSG':
> 
> sender='Angel'
> print data[len(sender)+2:string.find(data[len(sender)+2:],' ')]
> 
> It prints '' (an empty string).  Is my logic flawed, or does Python
> dislike a
> string splice determined by a function?

Your logic is flawed.  Break the splice limits into pieces:

max at oxygen:~% python
Python 2.0 (#2, Apr  4 2001, 19:28:30) 
[GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2
Type "copyright", "credits" or "license" for more information.
>>> import string
>>> sender='Angel'
>>> data=':Angel PRIVMSG Wiz :here is my message!'
>>> data[len(sender)+2:string.find(data[len(sender)+2:],' ')]
''
>>> len(sender)+2
7
>>> string.find(data[len(sender)+2:],' ')
7


-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ The revolution will not televised
\__/ Public Enemy
    Polly Wanna Cracka? / http://www.pollywannacracka.com/
 The Internet resource for interracial relationships.



More information about the Python-list mailing list