equivalent of bash "set -x" in Python

Chris Rebert clp2 at rebertia.com
Sun Sep 26 06:28:57 EDT 2010


On Sun, Sep 26, 2010 at 3:17 AM, TP <Tribulations at paralleles.invalid> wrote:
> Hi everybody,
>
> I am interested in having the possibility to print every Python commands in
> a script (for didactic purpose).
> So I am looking for some sort of equivalent of bash "set -x".
> Does it exist?

Not exactly. However, defining an appropriate function and passing it
to sys.settrace() would be the closest analogue:
http://docs.python.org/library/sys.html#sys.settrace

You could also step through your code manually using the debugger:
http://docs.python.org/library/pdb.html

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list