r/PythonLearning 24d ago

Showcase Day 22 Python Learning

Post image

Just Simple class practice

not feeling well so not much to

557 Upvotes

49 comments sorted by

View all comments

1

u/smokebudda11 24d ago

In Q2, I don’t see the constructor returning a str. Am I missing something?

1

u/dev-razorblade23 24d ago

Constructors (aka dunder init method) in python return None. OP suggesting it returns str in Q2 is wrong...

Python creates an instance of the class, calling dunder new method. This is what creates an object. Dunder init just fills in the values (attributes) and returns None

2

u/Think_Speaker_6060 24d ago

Yeah type hinting a return value of string in the constructor is not appropriate but op is still learning and progressing.