View Single Post
Old 01-23-2011, 04:32 AM   #74
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,475
Karma: 8025702
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by pchrist7 View Post
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.
chaley is offline   Reply With Quote