Insane crazy question - printing commands

Jean-Paul Calderone exarkun at divmod.com
Tue Nov 6 18:41:21 CET 2007


On Tue, 06 Nov 2007 19:09:21 +0200, Donn Ingle <donn.ingle at gmail.com> wrote:
>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).

See inspect.getsource().

Jean-Paul



More information about the Python-list mailing list