<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><br>How a function refer itself?<br> def f():<br> f() # fine... really???<br><br>consider these situations:<br>1) decorator<br> @xxx<br> def f():... # how can I access the wrapped version?<br><br>2) replace by other<br> def f(): f() # call second!!<br> a = T(f) # to call first<br> def f():...<br><br>3) refactor: rename function<br> # first version<br> def f():f()<br> -------------------<br> # second version, wrap it<br> def f():<br> log();<br> try: # to avoid indent<br> _f_impl()<br> except...<br> def _f_impl(): _f_impl() # hadnot we rename it!<br><br><br>solution:<br> # add __this_func__<br> class C:<br> @xxxx<br> def f(self):<br> self.f()<br> __class__.f(self)<br> __this_func__(self)<br><br><br><span id="transmark" style="display: none; width: 0px; height: 0px;"></span></div><br><br><span title="neteasefooter"><p> </p></span>