unicode error

2006-03-17 Thread Allerdyce . John
I have this python code: print >> htmlFile, ""; But that caues this error, and I can't figure it out why. Any help is appreicate File "./run.py", line 193, in ? print >> htmlFile, ""; UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 9: ordinal not in range(128) Thanks.

need some help in reading error message

2006-03-16 Thread Allerdyce . John
I need some help in reading error message: which line has problem? line 233? or line 37? Thank you. $ ./read2.py log.xml Traceback (most recent call last): File "./read2.py", line 233, in ? parser.parse(open(inputFileName)) File "/usr/lib/python2.4/site-packages/_xmlplus/sax/expatreader.p

Is there a python library to parse C++ code file?

2006-03-16 Thread Allerdyce . John
Is there a python library to parse C++ code file? If yes, can you please tell me where is it? Thank you. -- http://mail.python.org/mailman/listinfo/python-list

put multiple condition in if statement

2006-03-10 Thread Allerdyce . John
Hi, How can I put multiple condition in if statement? I try this, but I can't get that to work. if ( (str != " ") && (str != "") ): Any help is appreciated. Thank you. -- http://mail.python.org/mailman/listinfo/python-list

Do I need to convert string to integer in python?

2006-02-26 Thread Allerdyce . John
Do I need to convert string to integer in python? or it will do it for me (since dynamic type)? In my python script, I have this line: x /= 10; when i run it, I get this error: TypeError: unsupported operand type(s) for /=: 'unicode' and 'int' I want to divide x by 10 and assign that value b

Re: How to use python regular expression to substitute string value

2006-02-26 Thread Allerdyce . John
When I try your idea, I have this error x, y, width, height = re.findall(pattern, str)[0] IndexError: list index out of range How can I use findall to handle error case? i.e. what if there is no match? how can I handle it gracefully? -- http://mail.python.org/mailman/listinfo/python-list

Re: How to use python regular expression to substitute string value

2006-02-26 Thread Allerdyce . John
okay, but I have a simpler question, how can I split using only "\n"? I try this: strings = node.data.split("\n"); print node.data for str in strings: print str where node.data has multiple lines, but in the for loop, I don't see str gets pr

Re: How to use python regular expression to substitute string value

2006-02-26 Thread Allerdyce . John
Thanks. But i don't understand why I need to do this: x. . area = map (lambda x: int(x), re.findall (pattern, line)[0] if i have the value already by doing this: x, y, width, height, area = re.findall(pattern, line)[0] print "rect x=\"%(x)s\" y=\"%(y)s\" width=\"%(width)s\" height=\"%(height)s\"

How to use python regular expression to substitute string value

2006-02-26 Thread Allerdyce . John
Hi, I am new to python. I would like to know how to use python regular expression to substitute string value? I have an input string like this: x:11 y:0 w:760 h:19 area:14440 areaPerCent:0 totalAreaPerCent:-3.08011e+16 type:3 path:///-/1/1 and I would like to convert it to: rect x="11" y="0" width