About 475,000 results
Open links in new tab
  1. python - How do I call a function from another .py file ... - Stack ...

    function(a, b) Note that file is one of Python's core modules, so I suggest you change the filename of file.py to something else. Note that if you're trying to import functions from a.py to a file called b.py, …

  2. In Python, what happens when you import inside of a function?

    What are the pros and cons of importing a Python module and/or function inside of a function, with respect to efficiency of speed and of memory? Does it re-import every time the function is run, or

  3. 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)

  4. python - How to use the __import__ function to import a name from a ...

    Mar 21, 2012 · Because this function is meant for use by the Python interpreter and not for general use it is better to use importlib.import_module () to programmatically import a module.

  5. module - Import functions in Python - Stack Overflow

    Apr 27, 2019 · import functions from functions import a, b, c functions.x = 1 functions.y = 2 functions.z = 3 print(a()) print(b()) print(c()) Because Python is lexically scoped, each function keeps a reference to …

  6. Importing from a relative path in Python - Stack Overflow

    Python 2.6 and 3.x supports proper relative imports, where you can avoid doing anything hacky. With this method, you know you are getting a relative import rather than an absolute import.

  7. python - Use 'import module' or 'from module import ... - Stack Overflow

    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 practices in mind. Bas...

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

    I have this folder structure: application ├── app │ └── folder │ └── file.py └── app2 └── some_folder └── some_file.py How can I import a function from file.py, from within som...

  9. python - importing functions from another jupyter notebook - Stack …

    May 29, 2018 · 5 Something I've done to import functions into a Jupyter notebook has been to write the functions in a separate Python .py file then use the magic command %run in the notebook. Here's an …

  10. python - Import a file from a subdirectory? - Stack Overflow

    Aug 11, 2009 · import lib.BoxTime Which resulted: Traceback (most recent call last): File "./tester.py", line 3, in <module> import lib.BoxTime ImportError: No module named lib.BoxTime Any ideas how to …