All Questions
9 questions
6
votes
4
answers
1k
views
Python: Is it a good practice to rely on import to execute code?
In Python, is it a good practice to rely on import to execute code, like in the example below?
The code in mod.py is supposed to load some config, and needs to be executed once only. It can use more ...
2
votes
1
answer
50
views
Import python from sibling folder without -m or syspath hacks
So I've spent the last three days trying to figure out a workable solution to this problem with imports.
I have a subfolder in my project where I have scripts for database control, which has sibling ...
1
vote
0
answers
104
views
Problem with folder structure and imports for creating app with pyInstaller
This is more like a architectural question, and i understand that this is possible the wrong place to ask. I have the following folder structure:
- BUILD
- build
- dist
- project_1.spec
- ...
0
votes
2
answers
529
views
ModuleNotFoundError: No module named 'redsquare.moduloMatriculas'" DJANGO
I'm trying to import a models.py file from moduloMatriculas in moduloFormaturas, however the error "ModuleNotFoundError: No module named 'redsquare.moduloMatriculas'" occurs
redsquare means the name ...
2
votes
0
answers
72
views
How to get absolute imports to work in Python?
I know there are dozens of similar questions about Python imports, so I'll try to phrase it a bit differently. I'll spare you the details of the days of desperation that lie behind me, and instead ...
2
votes
2
answers
723
views
Python 3 - Modules and Packages Mess - Architecture
Some months ago y started working in a small project that over the time became big. It started with a few python files:
project
│ program_1.py
│ program_2.py
We continue adding more programs, ...
0
votes
1
answer
242
views
Python class, data structure and proper architecture
I'm writing a program, which request user information from different services, puts them together in some ways. manages stuff and does some slack interaction.
All my python projects get problematic at ...
0
votes
3
answers
387
views
Python architecture - import extra modules, or import modules in code execution section?
I have a module that defines a class which instantiates a class from one of two (or more) other modules. Below are a couple of code examples. In the first example, two modules are imported, but only ...
2
votes
2
answers
5k
views
Infinite loop with Python imports; looking for Pythonic way
My team is working on huge project with Django. For sake of simplicity, here's plain Python to illustrate the problem (original problem has models and apps instead of classes (I know that both are ...