Let dataclasses write your dunder methods. 🧵
The dataclass decorator writes __init__, __repr__, and __eq__ for you:
from dataclasses import dataclass
@dataclass
class Comment:
text: str
line: int
#Python #DailyPythonTip
Let dataclasses write your dunder methods. 🧵
The dataclass decorator writes __init__, __repr__, and __eq__ for you:
from dataclasses import dataclass
@dataclass
class Comment:
text: str
line: int
#Python #DailyPythonTip
but it’s still slow
but it’s still slow
from dataclasses import dataclass
@ dataclass
class Person:
gender:Any = None
from dataclasses import dataclass
@ dataclass
class Person:
gender:Any = None
https://zenn.dev/dalab/articles/61f06f6b516f4e
https://zenn.dev/dalab/articles/61f06f6b516f4e
jmduke.com/posts/post/f...
jmduke.com/posts/post/f...
The blog in is Japanese, but that’s what Google Translate is for.
Discusses Basics of Python Development (Project Management and Code Quality) "
The blog in is Japanese, but that’s what Google Translate is for.
Discusses Basics of Python Development (Project Management and Code Quality) "
www.youtube.com/watch?v=D4PV...
www.youtube.com/watch?v=D4PV...
📦 https://packages.debian.org/dataclass-to-latex
🔗 https://github.com/javimosch/supercli
#dataclass-to-latex #supercli
📦 https://packages.debian.org/dataclass-to-latex
🔗 https://github.com/javimosch/supercli
#dataclass-to-latex #supercli
much easier than I thought
from dataclasses import dataclass
@dataclass
class A:
value: int = 0
@dataclass
class B(A):
value: int = 1
print(A())
print(B())
much easier than I thought
from dataclasses import dataclass
@dataclass
class A:
value: int = 0
@dataclass
class B(A):
value: int = 1
print(A())
print(B())
#Python #programadores #bolhatech #dicas #linguagemPython #dicapython
#Python #programadores #bolhatech #dicas #linguagemPython #dicapython
Lazily(?) got through this while fighting post-vaccine symptoms. Part 2 is such a simple change, but handling vertical pushes changes the approach dramatically.
(I also love dataclass!)
Lazily(?) got through this while fighting post-vaccine symptoms. Part 2 is such a simple change, but handling vertical pushes changes the approach dramatically.
(I also love dataclass!)
Dataclasses aren't orderable by default. Add `order=True` to auto-generate comparison methods like __lt__ & __gt__.
This makes sorting/compare tasks seamless! Check out an example 👇
How do you use dataclasses in your projects? 🚀
Dataclasses aren't orderable by default. Add `order=True` to auto-generate comparison methods like __lt__ & __gt__.
This makes sorting/compare tasks seamless! Check out an example 👇
How do you use dataclasses in your projects? 🚀
1. create a __init__ method
2. use a tool (like the dataclass decorator) to create a __init__ method
3. inherit from a class that has a useful __init__ method method.
1. create a __init__ method
2. use a tool (like the dataclass decorator) to create a __init__ method
3. inherit from a class that has a useful __init__ method method.