Skip to main content
1 vote
3 answers
54 views

I'm trying to subclass the AbstractWrappedSolver dataclass from the jax library diffrax. The class has this definition: class AbstractWrappedSolver(AbstractSolver[_SolverState]): """...
Ben's user avatar
  • 603
Advice
0 votes
2 replies
97 views

I'm learning for my Introductory Programming Course in uni and I don't have an overview over the different cases when it comes to Setters and Getters and the slides are not quite helpful. So for ...
alex thyo's user avatar
7 votes
1 answer
170 views

I'm currently working on a library that uses dataclasses.dataclass classes for data structures. I'm utilizing the metadata argument of the dataclasses.field() method to inject custom library ...
JackTheFoxOtter's user avatar
1 vote
1 answer
71 views

Why can't I simply define a 'derived' variable in the class definition and assign it a calculated value, instead of using the __post_init__ method to do so? Example: from dataclasses import dataclass, ...
Purav Dagli's user avatar
Best practices
2 votes
3 replies
136 views

I find Python's dataclasses to be incredibly convenient. They cut out a ton of boilerplate code (no more needing to write self.foo = foo for every __init__ parameter, and no more needing to spell out ...
Lux's user avatar
  • 352
-2 votes
1 answer
73 views

import dataclasses @dataclasses.dataclass class MyClass: a: int b: int = dataclasses.field(default=0, init=False) m = MyClass(a=0) print(repr(m)) # prints: "MyClass(a=0, b=0)" # `...
Guti_Haz's user avatar
  • 2,752
0 votes
0 answers
118 views

How is it possible using xsdata for the generation of the model (dataclass) from an XSD with choice elements, to perform validations on those choices, so that it only allows one of them to be set? XSD ...
Luis Daniel's user avatar
3 votes
1 answer
80 views

I am writing a Python config script that creates an array of input files in a domain-specific language (DSL), so my use case is a bit unusual. In this scenario, we want medium-level users to be able ...
globglogabgalab's user avatar
2 votes
2 answers
242 views

I have this data class: @dataclass class User: id: str name: str pwd: str picture: str url: str age: int # many, many more attributes Now, I have to make all of the ...
Aadvik's user avatar
  • 1,522
1 vote
1 answer
216 views

I have a dataclass for a set of timers. Each instance of the dataclass can have a different number of timers. The number of timers in a specific instance is fixed but can vary between instances. I'd ...
JKomp's user avatar
  • 109
2 votes
2 answers
108 views

I have the following simple class in Python: class Point: def __init__(x: int, y: int | None = None): self.x = x self.y = y if y is not None else x How can the same thing be ...
Get rid of LLM slop's user avatar
0 votes
1 answer
136 views

I want a class that encapsulates data with some meta information. The data changes during runtime. I want to safe it for evaluation. The class looks like this: from dataclasses import dataclass, ...
Durtal's user avatar
  • 1,108
0 votes
1 answer
58 views

I'm trying to convert a json array to a Python list of typed objects. It's data from Teltonika FOTA The call result_list = fromlist(FotaDevice, intermediate_list) is failing with the error message ...
Hecatonchires's user avatar
1 vote
0 answers
108 views

Consider the following example: from dataclasses import dataclass import dataclasses from typing import Self @dataclass class Dataclass: a: int b: str c: list[int] def update_attrs(...
bzm3r's user avatar
  • 4,684
4 votes
3 answers
177 views

I'm currently working with a dataclass (defined in one of the dependencies I'm currently working with inside of my project), which is defined similar to this snippet: from dataclasses import dataclass ...
Jaime 's user avatar
  • 143

15 30 50 per page
1
2 3 4 5
70