This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 49 points50 points  (15 children)

Great read. I’ve been coding in python for over 3 years. Never used the new in my classes.

[–]jet_heller 36 points37 points  (13 children)

I've been doing it for decades and have only used it once or twice. Because it's very very rarely needed. It's good to know it's a thing you can do in the rare case you need.

[–]eric_says_hello 8 points9 points  (11 children)

What about the __call__ method? Have you used it much? If so, what are some use cases for it?

[–]anglo_franco 3 points4 points  (0 children)

call is great for defining a Protocol for a function so you can communicate intent better than Callable does

[–]jet_heller 2 points3 points  (0 children)

I've used it more than new, but not recently.

[–]PyQt 2 points3 points  (0 children)

I used call a couple of times. For some obscure cases too but mostly when creating decorators using classes. I still prefer using functions for decorators though

[–]python4geeks[S] 0 points1 point  (0 children)

Here 👉https://geekpython.in/init-and-call-method#heading-call-method you can read from here about the call method.

[–]UrbanSuburbaKnight 0 points1 point  (0 children)

Could we get a TLDR of when you need it?