[melbourne-pug] Coding idiom

Justin Warren daedalus at eigenmagic.com
Tue May 9 01:37:36 CEST 2006


On Mon, 2006-05-08 at 23:40 +1000, Bill Birch wrote:
> On Fri, 5 May 2006 02:27 pm, Justin Warren wrote:

> >
> > Truly deprecated code raises a *mumble*Deprecated warning.
> How about yet another decorator?
> 
> def deprecated(f):
>     def new_f(*args, **kwds):
>         print "warning: deprecated function", f.func_name
>         return f(*args, **kwds)
>     new_f.func_name = f.func_name
>     return new_f
> 
> @deprecated
> def lepard(a, *args, **kwargs): 
>     print a, args, kwargs
> 
> >>> lepard(1,2,3, four=4)
> warning: deprecated function lepard
> 1 (2, 3) {'four': 4}

Ah, no. I meant PEP 230, I believe, and the DeprecationWarning category.
You could build a decorator to spit one out, I guess.

-- 
Justin Warren <daedalus at eigenmagic.com>



More information about the melbourne-pug mailing list