- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use multiple modules with Python import Statement?
To import multiple modules with a single import statement, just separate the module names by commas. For example,
>>> import math, sys, os
If you want to change the name under which the modules are imported, just add as after each module name followed by module alias. For example,
>>> import math as Mathematics, sys as system
If you have a list of modules you want to import as strings, then you can use the inbuilt __import__(module_name). For example,
>>> modnames = ["os", "sys", "math"] >>> for lib in modnames: ... globals()[lib] = __import__(lib)
- How to install and import Python modules at runtime?
- How we can import Python modules in Jython?
- How we can import Python modules without installing?
- What is the use of import statement in Python?
- Python import modules from Zip archives (zipimport)
- How to use remote python modules?
- How can I import modules for a Python Azure Function?
- How to use multiple conditions in one if statement in Python?
- How we can bundle multiple python modules?
- What is the use of "from...import" Statement in Python?
- What is the use of "from...import *" Statement in Python?
- How to use Python modules over Paramiko (SSH)?
- How to use else statement with Loops in Python?
- How to import Python modules by default at the time of program starts?
- Can we iteratively import python modules inside a for loop?