r/Python • u/declspecl • 3d ago
Discussion Constructors: __init__, __new__, both, neither?
Hi all, I'm doing some research on what programmers believe is the class constructor in Python. I made a poll here: https://strawpoll.com/05ZdzVzdmn6 and would appreciate all responses, thanks!
0
Upvotes
2
u/ToddBradley 2d ago
I came to Python by way of Java and C#, and have been using it weekly for the past several years. I have never once used
__new__
, only__init__
. And of code I've maintained that was written by others on a few different projects, I haven't seen a single person use__new__
.So I voted
__init__
, because for the colloquial use of the word "constructor", that's what it seems like the vast majority of people use.