I have the following module: #! /usr/bin/python COG_DEBUG=1 def wrapper( dd ): if dd == 1: def dfunc( *args ): print "print ", for ii in args: print repr(ii) print "compd dfunc" return dfunc else: def nfunc( *args ): pass print "compd nfunc" return nfunc dbgprint = wrapper(COG_DEBUG) print "dbgprint = ", repr(dbgprint) dbgprint("called from def hunk") print "hello1"
This does what I want, but when I use this code inside cog then the call to dbgprint doesn't do anything. Here's the input to cog: #! /usr/bin/python [[[cog import cog def wrapper( dd ): if dd == 1: def dfunc( *args ): cog.out( "print " ) for ii in args: cog.out( repr(ii) ) print print "compd dfunc" return dfunc else: def nfunc( *args ): pass print "compd nfunc" return nfunc dbgprint = wrapper(COG_DEBUG) print "dbgprint = ", repr(dbgprint) dbgprint("called from def hunk") ]]] [[[end]]] print "hello1" [[[cog dbgprint( "Hello from dbg" )]]] [[[end]]] print "Doo dis" and this is the cmdline: cog.py -D COG_DEBUG=1 -d -o d1out.py d1.py And the output is just #! /usr/bin/python import sys print "hello1" print "Doo dis" DOes anyone have any ideas? :-( -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net -- http://mail.python.org/mailman/listinfo/python-list