[Python-Dev] Re: String module

François Pinard pinard@iro.umontreal.ca
31 May 2002 14:22:34 -0400


[François]
>     >> By the way, I wonder why the `_' in `sys._getframe()'.

[Guido]
>     >> To discourage people from using it.

[Barry]
> Because [the previous way] is slow, hard to remember, and too magical.

That is, in short, discouraging, exactly as per the wish of Guido! :-)

A bit more seriously, it is fun writing:

    try:
        frame = sys._getframe(1)
    except AttributeError:
        frame = sys.exc_info()[2].tb_frame.f_back

putting the error to good use whenever `_getframe' is not available!

-- 
François Pinard   http://www.iro.umontreal.ca/~pinard