hi there,
i have an object reference "_sre.SRE_Pattern object at 0x01180C40"
how do i convert this into the string representative?
i am creating a simple dom oriented code project that takes in a .txt file and then prints it out in xml format.
the txt file im using only has this in it
"1 COURSE STAFF MEMBERS"
The print out of it returns this
>>> <?xml version="1.0" ?>
<2003 Course Outline>
<<_sre.SRE_Pattern object at 0x01180C40>/>
</2003 Course Outline>
as you can see 'repr(keyRE)' doesnt work
i would like the string "<COURSE STAFF MEMBERS>" and not
<_sre.SRE_Pattern object at 0x01180C40>
how do i do this???
thankyou
i have an object reference "_sre.SRE_Pattern object at 0x01180C40"
how do i convert this into the string representative?
i am creating a simple dom oriented code project that takes in a .txt file and then prints it out in xml format.
Code:
import re
from xml.dom.minidom import *
def main():
f = open('1.txt', 'r')
text = f.readlines()
f.close()
doc = Document()
co = doc.createElement("2003 Course Outline")
doc.appendChild(co)
keyRE = re.compile('(^[0-9])\t(\b[A-Z])\n')
for line in text:
firstLine = repr(keyRE) #????????
co2 = doc.createElement(firstLine)
co.appendChild(co2)
print doc.toprettyxml(indent=" ")
if __name__ == '__main__':
main()
the txt file im using only has this in it
"1 COURSE STAFF MEMBERS"
The print out of it returns this
>>> <?xml version="1.0" ?>
<2003 Course Outline>
<<_sre.SRE_Pattern object at 0x01180C40>/>
</2003 Course Outline>
as you can see 'repr(keyRE)' doesnt work
i would like the string "<COURSE STAFF MEMBERS>" and not
<_sre.SRE_Pattern object at 0x01180C40>
how do i do this???
thankyou