new command for getting traceback?

Pete Shinners shredwheat at mediaone.net
Sun Feb 4 16:42:30 EST 2001


one trick in python i've always thought was bizarre was getting
the current stack trace by raising a false exception.

        import sys
        try:
            raise None
        except:
            return sys.exc_info()[2].tb_frame

obviously grabbing the current stack is usually a sign of some
sort of "magic ahead", this is one of those things that is a
bit obscure. even harder from inside my C extension modules. It
would make things a bit nicer and more understandable if there
was some sort of traceback() builtin. (accessable from C too!)






More information about the Python-list mailing list