On Jun 11, 10:28 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
Since there is no way to distinguish the two cases by the arguments,
def deprecated(func=None, replacement=None):
if replacement:
# handle the case where a replacement has been given
elif func:
# handle the case
On Fri, Jun 17, 2011 at 4:27 AM, bruno.desthuilli...@gmail.com
bruno.desthuilli...@gmail.com wrote:
On Jun 11, 10:28 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
Since there is no way to distinguish the two cases by the arguments,
def deprecated(func=None, replacement=None):
if replacement:
On Jun 17, 3:53 pm, Ian Kelly ian.g.ke...@gmail.com wrote:
That works, but I would be concerned about forgetting to specify the
argument by keyword
(snip funny side effect description)
Also, as in my suggestion, it doesn't seem
like a big improvement to have to type out replacement= when
Giampaolo Rodolà wrote:
I've written this decorator to deprecate a function and (optionally)
provide a callable as replacement
I can see providing the replacement function so that you can say, for
example, you are calling a deprecated function -- function xyz is the
replacement.
If your
I wrote a little library that does this a couple weeks ago, it's on
pypi: http://pypi.python.org/pypi/Decorum/. It's pretty simple, the
last example illustrates how to do what you want. After thinking about
it though, I think it's probably not a great idea to allow the
parenthesis to be omitted.
I've written this decorator to deprecate a function and (optionally)
provide a callable as replacement
def deprecated(repfun=None):
A decorator which can be used to mark functions as deprecated.
Optional repfun is a callable that will be called with the same args
as
On Sat, Jun 11, 2011 at 1:27 PM, Giampaolo Rodolà g.rod...@gmail.com wrote:
@deprecated()
def foo():
return 0
This is equivalent to:
foo = deprecated()(foo)
@deprecated(some_function)
def foo():
return 0
foo = deprecated(some_function)(foo)
@deprecated
On 6/11/2011 3:27 PM, Giampaolo Rodolà wrote:
I've written this decorator to deprecate a function and (optionally)
provide a callable as replacement
def deprecated(repfun=None):
A decorator which can be used to mark functions as deprecated.
Optional repfun is a callable