Here's a puzzle...

TheDustbustr thedustbustr at aol.com
Sat Jul 21 19:56:40 EDT 2001


I'm trying to split the following string called data into four variables:

:Angel PRIVMSG Wiz :here is my message!

(so data=':Angel PRIVMSG Wiz :here is my message!') with an outcome of:

sender='Angel'
command='PRIVMSG'
rcpt=Wiz'
message='here is my message!'

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?

And if you are up to it, feel free to help me splice (correct terminology,
parse?) for variables rcpt and message ;)

Many thanks, Dustin



More information about the Python-list mailing list