Skip to content

Instantly share code, notes, and snippets.

@tritium21
Last active June 29, 2016 20:22
Show Gist options
  • Save tritium21/84d3d0a13ea562c579c3 to your computer and use it in GitHub Desktop.
Save tritium21/84d3d0a13ea562c579c3 to your computer and use it in GitHub Desktop.
These are my hacks
# Punich those who import *
__all__ = type('__all__', (object,), {'__getitem__': lambda self, index: __import__('types').FunctionType(compile('raise ImportError("Loli Haet \'from foo import *\'")', __name__, 'single'), globals())()})()
@tritium21
Copy link
Author

Seriously, If you use this, you are doing hacks. I mean, seriously, you are breaking (intentionally) parts of the import mechanism. If you don't want people to from your_module import *. do __all__ = []. The point of this is to punish the importer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment