strings problem

Jimmy verma jim_938 at
Fri Jul 4 19:41:56 CEST 2003

Hello *.*

Can you please tell me how can i have the output in no's, instead of string 
from this program:

import re
import string

def csNumEncode(num):
    if(num>=-107 and num<=107):
        return chr(num+139)
    elif(num>=108 and num<=1131):
        return chr(((num-108)/256)+247) + chr((num-108)%256)
        print 'do nothing'

re_num = re.compile("\-?[0-9]+(\.[0-9]+)?")

def CompileCS(source):
  for tkn in re.split('[ \n\t]+', source):
    print "Token: %s"%tkn
    if re_num.match(tkn):
        result = result + csNumEncode(string.atoi(tkn))
        raise SyntaxError, "%s is invalid operator"%tkn
  return result

src1 = '50  800'

t = CompileCS(src1)

print t

The output is

Token: 50
Token: 800

Instead of this i want the output should be in no's like this:

Your suggestions will be welcomed.

Thanks a lot.


Looking for love? Yearning for friendship? 
You're in the right place.

More information about the Python-list mailing list