Movatterモバイル変換


[0]ホーム

URL:


[Python-ideas] add variable "__this_func__" inside all functions' locals

Ryan Hiebertryan at ryanhiebert.com
Tue Feb 28 21:54:14 EST 2017


> On Feb 28, 2017, at 8:14 PM, 语言破碎处 <mlet_it_bew at 126.com> wrote:>> We need not care other functions, just the "current" one.>     Other functions are definitely out of our control.> My last example distinguish 3 cases:>     self.f()            # object/overloaded version>     __class__.f(self)   # decorated version>     __this_func__(self) # prime versionIf your decorator uses `functools.wraps` or `functools.update_wrapper` (it should, for lots of reasons, and many, perhaps most, third party wrappers do), then you can access the wrapped function as `decorated.__wrapped__`.Seehttps://docs.python.org/3/library/functools.html#functools.update_wrapper-------------- next part --------------An HTML attachment was scrubbed...URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170228/efb50ac0/attachment.html>


More information about the Python-ideasmailing list

[8]ページ先頭

©2009-2026 Movatter.jp