Linked Questions
11 questions linked to/from Importing classes from different files in a subdirectory
0 votes
0 answers
260 views
Using the constructor of a class in a different folder Python [duplicate]
I have a set of classes each with a constructor. These classes are in a folder (lets call this folder ABC). I have a separate python file (lets call this file PROJECT) that is in the parent folder of ...
969 votes
20 answers
1.7m views
How to import the class within the same directory or sub directory?
I have a directory that stores all the .py files. bin/ main.py user.py # where class User resides dir.py # where class Dir resides I want to use classes from user.py and dir.py in main.py. ...
7 votes
2 answers
5k views
Namespacing and classes
I'm trying to write some (in my opinion) readable code in Python. I need a module that will contain a number of classes. Theoretically I know everything that is needed to accomplish this: I can simply ...
2 votes
1 answer
1k views
Get all functions of a module
A project has the following structure: modulename ├── __init__.py │ ├── one │ ├── function_1.py │ ├── function2.py │ └─── __init__.py │ └── two ├── another_function.py ├── ...
1 vote
0 answers
828 views
How to import all modules in a package as a list?
Okay, so I'm trying to find a way to get a list of all modules in a package, into a variable. My file structure is as such: main/ app.py __init__.py modules/ __init.py mod_1.py ...
0 votes
0 answers
780 views
best way to register all classes in a folder in python
I am working as a summer intern at a fairly large company, me and another intern has been tasked with writing a background service from scratch in python(with given specifications). I can't say that I ...
1 vote
0 answers
329 views
How to create a list of objects based on all classes in a folder?
If I have a class like this: class A(object): def __init__(self): self.dynamic_objects = [] And a subfolder in the same location with a variable amount of files each with one class that ...
2 votes
0 answers
191 views
import class from different file in another folder not working [duplicate]
I already took a look at this solution Importing classes from different files in a subdirectory , however it's still not working for me. I have my __init__.py file where I make the import: from api....
0 votes
1 answer
90 views
Call from class in module without specifying its name
Can I import a class from a module, the same way as I can import the module like: from module_name import * so that I don't have to specify the "module.class" names every time I want a variable in it?...
0 votes
0 answers
87 views
Importing all needed modules into a Python mother module
I'm new to Python so I'm sorry if this question seems dumb, but I couldn't find specific help on that. I'm working on a testing project where I wanted all the logic to be loaded into a mother ...
0 votes
1 answer
52 views
Proper way of setting classes and constants in python package
I'm writing a small package for internal use and come to a design problem. I define a few classes and constants (i.e., server IP address) in some file, let's call it mathfunc.py. Now, some of these ...