Insane crazy question - printing commands
Donn Ingle
donn.ingle at gmail.com
Tue Nov 6 12:09:21 EST 2007
Hi,
I'm doing something odd with pycairo and friends and I want to see what
commands are coming out of my objects.
Here's some code:
class Box:
def draw()
self.context.set_source_rgb(1, 0, 0)
self.context.rectangle(0, 00, 50, 50)
self.context.fill()
Box.draw() draws a red box, all fine. But, I *also* want it to output the
actual commands within the draw def to the console (or a file).
At the moment I am doing this:
class Box:
def draw()
self.context.set_source_rgb(1, 0, 0)
self.context.rectangle(0, 00, 50, 50)
self.context.fill()
print """
self.context.set_source_rgb(1, 0, 0)
self.context.rectangle(0, 00, 50, 50)
self.context.fill()
"""
Do you see the form? Is there some <voodoo magic> python introspection way I
can perform that automagically without having to use the print statement?
Something like:
class Box:
def draw()
self.context.set_source_rgb(1, 0, 0)
self.context.rectangle(0, 00, 50, 50)
self.context.fill()
def dump():
<mystical mindblowing stuff involving deep magic>
See, I told you it was insane :)
\d
More information about the Python-list
mailing list