Last active
March 24, 2017 05:04
-
-
Save ggand0/5773e292b0b3990195edad7bd35a4c64 to your computer and use it in GitHub Desktop.
Preventing importing modules in Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # see: http://stackoverflow.com/questions/1350466/preventing-python-code-from-importing-certain-modules | |
| >>> import tensorflow | |
| >>> tensorflow.contrib | |
| <tensorflow._LazyContribLoader object at 0x1130b9050> | |
| >>> tensorflow.contrib.layers | |
| <module 'tensorflow.contrib.layers' from '/Users/pentiumx/.pyenv/versions/2.7.10/lib/python2.7/site-packages/tensorflow/contrib/layers/__init__.pyc'> | |
| >>> import sys | |
| >>> del tensorflow.contrib.layers | |
| >>> sys.modules['tensorflow.contrib.layers']=None | |
| >>> tensorflow.contrib.layers | |
| Traceback (most recent call last): | |
| File "<stdin>", line 1, in <module> | |
| AttributeError: 'module' object has no attribute 'layers' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment