On Apr 2, 10:09 pm, "erikcw" <[EMAIL PROTECTED]> wrote: > Hi, > > I'm parsing xml data with xml.sax and I need to perform some > arithmetic on some of the xml attributes. The problem is they are all > being "extracted" as unicode strings, so whenever I try to perform > math operations on the variables, I get this error: > > cr[0] = data['cls1']/data['ims1']; > TypeError: unsupported operand type(s) for /: 'unicode' and 'unicode' > > What do I need to do to extract the intergers from these unicode > strings (or better yet, parse them as intergers in the first place.). > I'm using the SAX method attrs.get('cls1',"") to parse the xml. Can I > "cast" the string into an interger? > > Thanks! > Erik
int(u'123') == 123 float(u'123') == 123.0 -- http://mail.python.org/mailman/listinfo/python-list