About 395,000 results
Open links in new tab
  1. python - How to import the class within the same directory or sub ...

    Jan 26, 2017 · from user import User from dir import Dir The same holds true if the files are in a subdirectory - put an __init__.py in the subdirectory as well, and then use regular import …

  2. How to import a class from another file in python?

    Nov 25, 2020 · Im new to python and have looked at various stack overflow posts. i feel like this should work but it doesnt. How do you import a class from another file in python? This folder …

  3. python - Importing class from another file - Stack Overflow

    Dec 22, 2016 · Before you mark it as duplicate please read my problem: I am trying to import a class from a file from a subdirectory > main.py > --->folder/ > ----->file.py and in file.py i have a

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

    Jun 28, 2009 · I want to inherit from a class in a file that lies in a directory above the current one. Is it possible to relatively import that file?

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

    In Python 3.4 and later, you can import from a source file directly (link to documentation). This is not the simplest solution, but I'm including this answer for completeness.

  6. python - What are the pros and cons of importing a class vs.

    In Python, there is no such thing as a variable that is global across more than one module. If you do from pkg.module import MyClass, then MyClass is in the global namespace of the module …

  7. How to dynamically load a Python class - Stack Overflow

    Feb 14, 2009 · 252 Given a string of a Python class, e.g. my_package.my_module.MyClass, what is the best possible way to load it? In other words I am looking for a equivalent …

  8. Importing modules inside python class - Stack Overflow

    Jul 28, 2011 · 86 I'm currently writing a class that needs os, stat and some others. What's the best way to import these modules in my class? I'm thinking about when others will use it, I want the …

  9. python - How to inherit class from different file? - Stack Overflow

    Oct 25, 2016 · This is because you either have to tell python the namespace through which it can access the class (my first solution) or explicitly import the class (my second solution).

  10. python - using import inside class - Stack Overflow

    Jun 29, 2016 · 30 I am completely new to the python class concept. After searching for a solution for some days, I hope I will get help here: I want a python class where I import a function and …