Importing modules

suggest change

Syntax

Remarks

Importing a module will make Python evaluate all top-level code in this module so it learns all the functions, classes, and variables that the module contains. When you want a module of yours to be imported somewhere else, be careful with your top-level code, and encapsulate it into if __name__ == '__main__': if you don’t want it to be executed when the module gets imported.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents