How to declare a module deprecated in python

You want to warn with a DeprecationWarning.

Exactly how you call it doesn’t matter that much, but the stdlib has a standard pattern for deprecated modules, like this:

# doc string, top-level comments, imports, __all__ =

import warnings
warnings.warn("the spam module is deprecated", DeprecationWarning,
              stacklevel=2)

# normal module code

See the 2.7 sets source for an example.

Leave a Comment

tech