Insane crazy question - printing commands

D

Donn Ingle

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,589
Members
45,100
Latest member
MelodeeFaj
Top