About 542,000 results
Open links in new tab
  1. How to do multiple imports in Python? - Stack Overflow

    You can use __import__ if you have a list of strings that represent modules, but it's probably cleaner if you follow the hint in the documentation and use importlib.import_module directly: import importlib requirements = [lib1, lib2, lib3, lib4, lib5] imported_libs = {lib: importlib.import_module(lib) for lib in requirements}

  2. 5. The import system — Python 3.13.3 documentation

    1 day ago · Python code in one module gains access to the code in another module by the process of importing it. The import statement is the most common way of invoking the import machinery, but it is not the only way. Functions such as importlib.import_module() and built-in __import__() can also be used to invoke the import machinery.

  3. How to import modules, packages, functions, etc. in Python

    May 12, 2023 · While it's possible to import multiple modules in a single import statement by separating them with commas, PEP8 discourages this practice. Instead, it recommends each import statement to be on a separate line. When importing functions, variables, classes, etc., using the from keyword, you can list multiple items separated by commas.

  4. Do Multiple Imports in Python - Online Tutorials Library

    In Python, you can import multiple modules using a few different methods. Here are some examples of how to do it: Import each module on a separate line. The simplest way to import multiple modules in Python is to import each one on a separate line. For example, suppose you want to import the math, random, and time modules. You could do it like ...

  5. Python: Importing Multiple Modules at Once - CodeRivers

    Jan 29, 2025 · Importing multiple modules at once can streamline your code and make it more efficient. This blog post will explore the various ways to import multiple modules in Python, along with best practices and common pitfalls. Table of Contents. Fundamental Concepts of Importing Multiple Modules; Usage Methods. Importing Multiple Modules Separately

  6. Use Multiple Modules with Python Import Statement

    In Python, you can use the import statement to use functions or variables defined in another module. Here are some code examples that demonstrate how to use multiple modules with Python import statement: Suppose you have two modules module1.py and module2.py that contain some functions:

  7. Mastering Python File Import: A Comprehensive Guide

    1 day ago · The simplest way to import a Python file (module) is to use the import keyword followed by the module name. ... When importing multiple modules, be careful not to have naming conflicts. If two modules have functions or variables with the same name, it can lead to unexpected behavior. One way to avoid this is by using the full module name when ...

  8. Mastering Python Import: A Comprehensive Guide - CodeRivers

    1 day ago · In the Python programming language, the `import` statement is a crucial mechanism that allows you to use code from other modules in your Python scripts. Modules are Python files containing Python definitions and statements. By importing modules, you can reuse existing code, organize your codebase more effectively, and leverage the vast ecosystem of Python libraries. This blog post will delve ...

  9. PythonImporting Modules and PIP | by Shaloo Mathew

    Jan 29, 2025 · As we discussed, to add functionality to your Python script, you can import modules using the import statement. This allows you to use the functions and classes defined in those modules....

  10. Preferred way to import multiple modules from package

    Mar 3, 2014 · What is the best way to import when you need several modules from a package? from PySide.QtGui import QGraphicsView, QAction, QKeySequence, QMenu, QCursor, QKeyEvent view = QGraphicsView() ... or

  11. Some results have been removed
Refresh