Quote:
Originally Posted by pchrist7
Had a change to fool around with your code.
For a start I think I'll stay with the print method.
|
No surprise, that. The trace would be useful in very limited circumstances. In most, it is data overload.
Quote:
One thing though - thought I could print mg like this
print "mg: %s" % (mg)
If mg is empty "mg: None" is printed as expected.
If mg has contents, "mg: <_sre.SRE_Match object at 0x0CFCF2A0>"
I had expected the text content of mg, so a bit confused.
|
You have stumbled across a python'ism. Printing object instances requires class-level support. The class must include some special methods that return a string representation of an instance of the class. SR match objects don't, so you need to make do with its API. For example, you can print mg.groups(), which will give you a list of all the matched groups. mg.group(0) will give you the entire matched string.