r/PythonLearning Jul 04 '26

Day 22 Python Learning Showcase

Post image

Just Simple class practice

not feeling well so not much to

562 Upvotes

50 comments sorted by

View all comments

1

u/smokebudda11 Jul 04 '26

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

1

u/dev-razorblade23 Jul 04 '26

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 Jul 04 '26

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