471,325 Members | 1,458 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Insane crazy question - printing commands

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 magicpython 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
Nov 6 '07 #1
0 853

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by cybertof | last post: by
reply views Thread by Shapper | last post: by
12 posts views Thread by Alex Clark | last post: by
6 posts views Thread by thomas.luce | last post: by
6 posts views Thread by Chris Dunaway | last post: by
3 posts views Thread by Richard MSL | last post: by
2 posts views Thread by Brad Pears | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.