Reputation: 2060
I have two python scripts Module1.py & Module2.py
Module1.py
has the following code
class Module1(object):
import clr
def __init__(self):
return None
def foo(self):
return None
Module2.py
is where I want to import Module1.py, so when I import Module1.py, here's what I get
so when I use the instance(module) of Module1.py, It display two items on Intellisence window i.e clr & foo, now my question is, is it possible to hide or restrict clr module functionalities outside Module1.py?
Upvotes: 2
Views: 1500
Reputation: 329
You can restrict the import to only import certain functionalities:
from X import a, b, c
You can also import the module into a protected variable:
X = __import__(‘X’)
Note: You can then define functions that access this protected variable, and return only the information you specify.
See this page for more information:
http://effbot.org/zone/import-confusion.htm
Upvotes: 1