Edvard Majakari <[EMAIL PROTECTED]> writes:

> (sorry, my NUA had lost the original article)
>>
>>> I'm curious -- what is everyone's favorite trick from a non-python
>>> language? And -- why isn't it in Python?
>
> Ability to tag some methods 'deprecated' as in Java (from 1.5
> onwards?). However, Python interpreter doesn't have to do it: pydoc and
> similar tools could detect, say, '@deprecated' in method comment string and
> warn user about it.

I don't see what's wrong with this code, and if one wanted, one could
also implement a decorator which calls warnings.warn when the function
is called:

def c_buffer(init, size=None):
    "deprecated, use create_string_buffer instead"
    import warnings
    warnings.warn("c_buffer is deprecated, use create_string_buffer instead",
                  DeprecationWarning, stacklevel=2)
    return create_string_buffer(init, size)

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to