Hello Phillip, On Fri, Jun 25, 2004 at 01:27:03AM -0400, Phillip J. Eby wrote: > About the only bit you couldn't do in pure Python would be decorating a > function defined in a nested scope, because "fast locals" aren't accessible > from pure Python. Would you believe it? Your implementation works just fine in this case too :-) sysmodule.c invokes PyFrame_FastToLocals and PyFrame_LocalsToFast around a call to a trace function, so that any change to f_locals from the trace function are actually correctly reflected into the frame. Excellent. Let's put this in the standard library and close the issue ;-) As an easy extension, decorate(attr=value, ...) could just assign attributes to the function object. Also, the fact that it works with other assignment statements is a bonus in my opinion, e.g.: class X: decorate(doc("Number of instances created.")) counter = 0 def __init__(self): X.counter += 1 However, it gets a bit lost if several variables are assigned to in one line. A bientot, Armin.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4