close
Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
55 views

I'd like to use the autodoc_typehints functionality of Sphinx (or the package sphinx_autodoc_typehints) to document fields of Python dataclasses, and I'm currently having trouble getting nice output. ...
mostsquares's user avatar
Best practices
0 votes
4 replies
96 views

I am trying to create a dataclass from a dynamically created class. I am doing something like [1] A = dataclass(type("ClsA", (), {"a":1})) However, the attribute a is not ...
A. Gocht's user avatar
  • 143
1 vote
3 answers
70 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
  • 679
Advice
0 votes
2 replies
198 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
191 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
74 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
253 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
-3 votes
1 answer
77 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,742
0 votes
0 answers
150 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
90 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
268 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,532
1 vote
1 answer
251 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
122 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 ...
Dominik Kaszewski's user avatar
0 votes
1 answer
166 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
59 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

15 30 50 per page
1
2 3 4 5
70