Howto or Tutorial for tokenize module for a newbie?

T

TY

Hi,

Can someone point me to a Howto or Tutorial for tokenize module for a
newbie? I read the documentation but it doesn't have a lot of info...
Thanks!
 
S

sreekant

TY said:
Hi,

Can someone point me to a Howto or Tutorial for tokenize module for a
newbie? I read the documentation but it doesn't have a lot of info...
Thanks!
Hi there

I don't know if I got your requirement. But I used a own version of
tokenizer which can use more than one delimiters. It is below. Hopefully
of some use to you.




def gettokens(dat):
delims={'=':'',';':',','=':'','(':'',')':'',':':'','[':'',']':''}
wlist=[]
appended=0
for n in string.split(dat,'\n'):
word=''
for m in n:
appended=0
if delims.has_key(m):
wlist.append(word)
wlist.append(m)
word=''
appended=1
else:
word=word+m
if appended==0:
wlist.append(word)
appended=1
wlist.append("\n")
return wlist

I am sure there are plenty of ways to write it better than that.

Good luck
sree
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top