470,643 Members | 1,199 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,643 developers. It's quick & easy.

decorators, function signature, and help()

After a week or so I'm finally getting accustomed to the pie-pre-def syntax.

Consider a simple-minded decorator that doesn't care about the signature of
the function it wraps:
def noisy(f): .... def g(*args, **kw):
.... print f.__name__
.... return f(*args, **kw)
.... return g
.... @noisy .... def naught():
.... "does nothing"
.... naught() naught

Now help() is less than helpful:
help(naught)

Help on function g:

g(*args, **kw)

While the docstring can easily be copied and might even be prefixed

g.__doc__ = "@noisy\n" + f.__doc__

the name currently can not. I do not see a way to preserve the signature
either. It seems that when decoration is a built-in feature that even has
syntax support it should play nice in these cases by default. Any ideas?
Could there be a smooth way to quote an argument list, e. g:

def f(a, b, c): pass
def g(/*same args as f*/): pass

Peter

Jul 18 '05 #1
1 2602
Read up on the following article on python-dev:

http://article.gmane.org/gmane.comp.python.devel/62057

HTH!

Heiko.
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Michael Sparks | last post: by
17 posts views Thread by daishi | last post: by
12 posts views Thread by Colin J. Williams | last post: by
4 posts views Thread by RebelGeekz | last post: by
2 posts views Thread by Guido van Rossum | last post: by
13 posts views Thread by vinjvinj | last post: by
reply views Thread by Gabriel Genellina | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.