Greg writes: > This is one of my top two Java features [1]. ... > [1] The other is compiler recognition of "@deprecated" in doc comments.
Hmm... what a good idea! Let's see... what exactly does "@deprecated" DO in Java? Why it causes the compiler to emit a warning if you use the function in question. Not a bad idea. Amusingly enough, the syntax is even the same in Python: ===== code ===== import warnings def deprecated(func): """This is a decorator which can be used to mark functions as deprecated. It will result in a warning being emmitted when the function is used.""" def newFunc(*args, **kwargs): warnings.warn("Call to deprecated function.") return func(*args, **kwargs) return newFunc ===== example ===== >>> @deprecated def func(x,y): return x + y >>> func(3,4) Warning (from warnings module): File "g:/Documents/Personal/Python/deprecated.py", line 10 warnings.warn("Call to deprecated function.") UserWarning: Call to deprecated function. 7 So... shall I go add this to the cookbook? -- Michael Chermside _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com