Barry A. Warsaw <ba...@python.org> added the comment:

> Usually the calling function object should be enough.

I want to at least provide some historical context on why sys._getframe() 
exists.  I originally wrote that to support PEP 292 and internationalization in 
Mailman.  This has since been extracted into the flufl.i18n package.  Here is 
the use of sys._getframe() in that library:

https://gitlab.com/warsaw/flufl.i18n/-/blob/main/src/flufl/i18n/_translator.py#L65

You can see that the reason this exists is to dig out the local and globals of 
the context in which the _() function is invoked.  This greatly reduces the 
need to repeat yourself in i18n call sites.

https://flufli18n.readthedocs.io/en/stable/using.html#substitutions-and-placeholders

I'm not saying sys._getfunc() is or isn't useful, but it won't change original 
need for sys._getframe().

----------
nosy: +barry

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46543>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to