General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Dr Gamma D
Indently
comments
Comments by "Dr Gamma D" (@DrDeuteron) on "5 Useful Dunder Methods In Python" video.
one common pythonic thing is, repr(instance) should return a string so that: >>>instance == eval(repr(instance)) is True, so something _like_: return f"{type(self).___name__}(}" + ", ".join(f'{k}={v}' for k, v in self.___dict___.items()) + ")" Also: note that these dunder methods are strongly typed and MUST return a str. You can also use the "dunder module" static class attribute to assist.
10
@nibblrrr7124 don't forget unicode() from 2x, but those backward quotes `foo` -> repr(foo) were weird. Though emacs knew about them,
3
What’s great about python is that you can test it in an interpreter about as fast as you can answer the question.
2
Every thing is a first class object in python
2
Do you mean the annotations? Like: Twopi : float = three: int + 0.1 : float + 41: int / pow(10: int, 3: int) ? Yes. And telling ppl dunder init returns None, I just can’t. Of dunder str returns str. Same for int, float, complex, etc….
1
@MarianoBustos-i1f oh. Yes, I turn those off all the time, esp when I'm writing a line that depends the prior line... ...it opens up and hides what I want to build off of and tells me a bunch of stuff I don't need to know.
1
For me, I love overloading operators, until I want to see where something happens in the code.
1
Luckily type hints don’t matter
1
Since which version? And is it pronounced bang r? Does anyone remember back quotes being assign to repr?
1
its dunder getitem, not get_item.
1
No, but there is a mifflin
1
Doesn’t type(self) work too?
1