Thomas Heller <[EMAIL PROTECTED]> writes: > 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)
Well, nothing's wrong there, and the same could be done with Java before. However, having a consistent deprecated string everywhere allows easier eg. automatic finding of such methods from documentation. Decorators also help here, but that requires version 2.3 or newer (which usually isn't a problem, but can be) Hey! I hadn't realized category parameter nor stacklevel in warnings module (just used a few times, never read the doc because I didn't need to). Neat, thanks. -- # Edvard Majakari Software Engineer # PGP PUBLIC KEY available Soli Deo Gloria! $_ = '456476617264204d616a616b6172692c20612043687269737469616e20'; print join('',map{chr hex}(split/(\w{2})/)),uc substr(crypt(60281449,'es'),2,4),"\n"; -- http://mail.python.org/mailman/listinfo/python-list