About 10,000,000 results
Open links in new tab
  1. How do I import other Python files? - Stack Overflow

    How do I import files in Python? I want to import: a file (e.g. file.py) a folder a file dynamically at runtime, based on user input one specific part of a file (e.g. a single function)

  2. python - What exactly does "import *" import? - Stack Overflow

    Mar 2, 2010 · In Python, what exactly does import * import? Does it import __init__.py found in the containing folder? For example, is it necessary to declare from project.model import __init__, …

  3. python - `from ... import` vs `import .` - Stack Overflow

    Feb 25, 2012 · I'm wondering if there's any difference between the code fragment from urllib import request and the fragment import urllib.request or if they are interchangeable. If they are …

  4. python - Importing files from different folder - Stack Overflow

    Relative import is working for me too Version: Python 3.13.7 folder structure app/ ├─ main.py ├─ helpers/ │ ├─ my_helper_file.py ├─ venv/ # virtual environment and I import functions from …

  5. python - Why is "import *" bad? - Stack Overflow

    The only argument is that Python supports "import *" - if the consensus is that it is bad, then the feature should be removed, perhaps in Python 4 when people are expecting pain, anyway.

  6. python - Use 'import module' or 'from module import'? - Stack …

    Oct 28, 2014 · I've tried to find a comprehensive guide on whether it is best to use import module or from module import. I've just started with Python and I'm trying to start off with best …

  7. How can I do relative imports in Python? - Stack Overflow

    Here is the solution which works for me: I do the relative imports as from ..sub2 import mod2 and then, if I want to run mod1.py then I go to the parent directory of app and run the module using …

  8. python - Importing modules from parent folder - Stack Overflow

    Apr 3, 2009 · 4) Import by prepending mainfolder to every import In this example, the mainfolder would be ptdraft. This has the advantage that you will not run into name collisions with other …

  9. How do I unload (reload) a Python module? - Stack Overflow

    Jan 13, 2009 · Python module’s code is recompiled and the module-level code re-executed, defining a new set of objects which are bound to names in the module’s dictionary by reusing …

  10. How to import a Python class that is in a directory above?

    Jun 28, 2009 · To load python code reliably, have that code in a module, and that module installed in python's library. Installed modules can always be loaded from the top level namespace with …