dynamic

For Django project (using VS Code), dynamic images not loading. Possible issue with baseURL

For Django project (using VS Code), dynamic images not loading. Possible issue with baseURL Question: I’ve started a Django project based off of a (Telusko/Travello) tutorial but using my own files. There’s data defined on Views.py for title, description, images for courses. It should populate containers in a row on homepage. Everything is getting populated …

Total answers: 1

Validate Pydantic dynamic float enum by name with OpenAPI description

Validate Pydantic dynamic float enum by name with OpenAPI description Question: Following on from this question and this discussion I am now trying to create a Pydantic BaseModel that has a field with a float Enum that is created dynamically and is validated by name. (Down the track I will probably want to use Decimal …

Total answers: 3

When using importlib to load a module, can I put it in a package without an __init__.py file?

When using importlib to load a module, can I put it in a package without an __init__.py file? Question: My Python application loads plugins from a user-specified path (which is not part of sys.path), according to the importlib documentation: import importlib.util import sys def load_module(module_name, file_path): spec = importlib.util.spec_from_file_location(module_name, file_path) module = importlib.util.module_from_spec(spec) sys.modules[module_name] = …

Total answers: 1

How to add decorator to dynamically create class

How to add decorator to dynamically create class Question: I want to convert this code to be dynamic: @external_decorator class Robot: counter = 0 def __init__(self, name): self.name = name def sayHello(self): return "Hi, I am " + self.name I can create the class dynamically, this way: def Rob_init(self, name): self.name = name Robot2 = …

Total answers: 1

Python Qt Creator new project base class QMainWindow not showing dynamic form.ui

Python Qt Creator new project base class QMainWindow not showing dynamic form.ui Question: I’ve installed Qt Creator v9.0.1 on Ubuntu 22.04 / Windows 10 and try to create a new project which shows an empty frame and not the loaded form.ui: Screenshot Screencapture Testcase: File | New Project: Application (Qt for Python) | Window UI …

Total answers: 1

How to get feedback from ComboBoxes created in a loop

How to get feedback from ComboBoxes created in a loop Question: I am trying to feed an unspecified number of comboboxes to a user. Once the user selects inputs for the combo boxes I want to be able to print out those combobox inputs after the submit button is clicked. Currently I can only print …

Total answers: 1

Class object attributes to list in a one liner

Class object attributes to list in a one liner Question: I have a list of class objects, e.g.: child1 = Child(Name = ‘Max’, height = 5.1, weight = 100) child2 = Child(Name = ‘Mimi, height = 4.1, weight = 80) my_object_list = [child1, child2] Is there a way to create a new list dynamically with …

Total answers: 1