debug print shortcut?

Roel Schroeven rschroev_nospam_ml at
Sun Jun 6 15:23:46 CEST 2004

John Mudd wrote:

> When debugging python, I add print statements such as these.  
> print 'i=%s' % `i`
> print 'foo()=%s' % `foo()`
> print 'a,b,c=%s' % `a,b,c`
> I just want to dump the value of a variable or expression.  But I
> don't like having to type the expression twice, everytime.  I can
> solve this in 'C' with a preprocessor macro.  Can it be solved in
> python?

def printdebug(s):
     print '%s = %s' % (s, `eval(s)`)

"Codito ergo sum"
Roel Schroeven

More information about the Python-list mailing list