Debugging Python ?
Anand Pillai
pythonguy at Hotpop.com
Tue Jul 29 08:53:26 EDT 2003
It would be nice if you could give a name
to your email address, i.e if you are not
that paranoid as it seems.
~Anand
logistix at cathoderaymission.net (logistix at cathoderaymission.net) wrote in message news:<3c91a864.0307282013.2acb2d1f at posting.google.com>...
> pedro.werneck at bol.com.br (Pedro Werneck) wrote in message news:<ef72fb2b.0307281449.6b144be7 at posting.google.com>...
> > I use:
> >
> > if __debug__: print "bla, bla, bla..."
> >
> > And I was just wondering if it's legal to define a "print" function...
> > isn't print a keyword ?
>
> Instead of defining "print" you can assign a custom class to
> sys.stdout. Then all the print statements get automagically
> redirected.:
>
> if __debug__:
> class newStdout:
> def write(self,string):
> print string
> else:
> class newStdout:
> def write(self,string):
> pass
>
> import sys
> sys.stdout = newStdout()
More information about the Python-list
mailing list