Sometimes we need to mark a function parameter as deprecated, using a decorator.
For instance:
@deprecated_param(version="0.2.3",
reason="you may consider using *styles* instead.",
deprecated_args='color background_color')
def paragraph(text, color=None, background_color=None, styles=None):
styles = styles or {}
if color:
styles['color'] = color
if background_color:
styles['background-color'] = background_color
html_styles = " ".join("{k}: {v};".format(k=k, v=v) for k, v in styles.items())
html_text = xml.sax.saxutils.escape(text)
return ('<p styles="{html_styles}">{html_text}</p>'
.format(html_styles=html_styles, html_text=html_text))
See https://github.com/tantale/deprecated/issues/8
I'm searching a good way to implement that.
Do you now any code examples in the Python Standard library or in famous open source projects (like Flask, Django, setuptools...)?