Friday, May 21, 2010

Recipe 577237: Prevent star imports (Python)

Recipe 577237
Use this code in your module to prevent people using the "from foo import *" syntax with your module.

@apply
class __all__(object):
    def __getitem__(self, _):
        raise ImportError("Star imports not supported")

No comments: