How to Import Only Parts From a Module in Python


In this example we will show how to import only parts from a module in Python.

Source Code

from mymodule import area

'''
The contents of the module named mymodule:
def area(width, height):
    return width * height

student1 = {
    'name': 'Jim',
    'age': 15,
    'id': 16
}
'''

area1 = area(5, 10)
print(area1)

Output:

50
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments