Python Classes But We Don’t Write __init__()

Liu Zuo Lin
Level Up Coding
Published in
3 min readApr 23, 2024

--

What I’m about to introduce to you might save you significant development time when writing Python classes — the built-in dataclasses module that makes writing classes a lot simpler.

Here’s a normal Dog class

class Dog:
def __init__(self, name, age):
self.name = name
self.age = age

dog = Dog('rocky', 5)

print(dog.name) # rocky…

--

--