Turns out that I’m always, repeat, always re-writing, and re-organizing my code. If you’re like me, you’ll want to leave your old functions or classes & methods in place while you re-write or move them. Then you’ll want to leave little tags everywhere there is an old call to one of these.
Seth Gibson (@voMethod on Twitter) suggested I use:
import warnings def myFunc(): warnings.warn('Please use code elsewhere', DeprecationWarning) pass
Which will notify you when this function gets called. But it won’t pester you. Just the first time you call it and when it gets changed. Very kewl trick.
Dug around and noticed that PyMEL had a decorator in pymel.internal.pwarnings that performed just as well but provides a little more Syntactic sugar:
from pymel.internal.pwarnings import deprecated @deprecated("Please use code elsewhere") def myFunc1(): pass myFunc1()
Good ‘ol PyMEL, delivers again.
Leave a Reply