Yes, this is essentially the same idea. You compile the codestring to
bytecode,
whereas I just evalue the codestring to a lambda function. We are
essentially implementing a runtime macro by hand. I wonder if there is
any alternative
approach to get the same result, without manipulation of the sourc
"Michele Simionato" <[EMAIL PROTECTED]> writes:
> I have realized today that defining decorators for functions
> with generic signatures is pretty non-trivial.
I've not completely read your post ;-), but I assume you're trying to do
something that I've also done some time ago. Maybe the following
I said it was very little tested! ;)
This should work better:
#
def _signature_gen(varnames, n_default_args, n_args,
rm_defaults=False):
n_non_default_args = n_args - n_default_args
non_default_names = varnames[:n_non_default_args]
default_names = varnames[n_non_default_args:n_args]
I have realized today that defining decorators for functions
with generic signatures is pretty non-trivial.
Consider for instance this typical code:
#
def traced_function(f):
def newf(*args, **kw):
print "calling %s with args %s, %s" % (f.__name__, args, kw)
return f(*args, *