Function name unchanged in error message

andrew cooke andrew at acooke.org
Sat Jan 30 18:13:06 EST 2010


On Jan 29, 1:09 pm, Michele Simionato <michele.simion... at gmail.com>
wrote:
> On Jan 29, 2:30 pm, andrew cooke <and... at acooke.org> wrote:
>
> > Is there any way to change the name of the function in an error
> > message?  In the example below I'd like the error to refer to bar(),
> > for example (the motivation is related function decorators - I'd like
> > the wrapper function to give the same name)
>
> Use the decorator module which does the right thing:http://pypi.python.org/pypi/decorator

curiously, decorator doesn't have this issue, because the way it
defines decorators uses *args.  so the error i gave cannot occur at
the level of the decorator - the extra arg is passed to the wrapped
function, and so the error message is correct because it is generated
by the inner function.

i need to look at my code; this might be the simplest solution of all.

thanks,
andrew



More information about the Python-list mailing list