Timeline for The Liskov Substitution Principle, and Python
Current License: CC BY-SA 4.0
17 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Sep 3, 2021 at 1:51 | history | edited | Chris Bouchard | CC BY-SA 4.0 |
Add note about calling class methods on instances
|
Sep 3, 2021 at 1:42 | history | edited | Chris Bouchard | CC BY-SA 4.0 |
Improve wording in a couple places
|
Sep 3, 2021 at 1:34 | comment | added | Chris Bouchard |
Yeah, I agree with you there, and I'm pretty sure I've seen it used that way in third-party libraries as well. I do see the utility in having something like the docs describe — a dedicated exception to indicate that you forgot something, kind of like Rust's todo!() macro — but then it would be handy to also have a NeverGonnaHappenError .
|
|
Sep 2, 2021 at 14:05 | vote | accept | Alex Waygood | ||
Sep 2, 2021 at 7:03 | comment | added | Alex Waygood |
Not a comment on your answer — but I find the documentation for NotImplementedError a little bizarre, frankly. I'm sure I've seen it used like that many times in the standard library, and I'd much prefer a helpful NotImplementedError message rather than the inexplicable NoneType is not callable error message you'd get if you replaced the method with None . It was also endorsed the other day by Raymond Hettinger on twitter, who's been a core dev for around 20 years now I believe! (I think he's also the author of Counter .) twitter.com/raymondh/status/1430565266136698882?s=21
|
|
Sep 2, 2021 at 1:57 | history | edited | Chris Bouchard | CC BY-SA 4.0 |
Replace "random" with "arbitrary"
|
Sep 2, 2021 at 1:53 | comment | added | Chris Bouchard |
Hopefully the new paragraph is more factual and helpful. (I'm realizing I had C++'s = delete feature in mind when I wrote that originally.)
|
|
Sep 2, 2021 at 1:51 | history | edited | Chris Bouchard | CC BY-SA 4.0 |
Rewrite section on overriding fromkeys
|
Sep 2, 2021 at 1:33 | comment | added | Chris Bouchard | When I wrote that, I was thinking you could, but now I'm not sure at all. There are tricks to hide a method inherited from a parent class, but not to remove. On reflection, I'm going to rework that part of my answer. | |
Sep 1, 2021 at 11:08 | comment | added | Alex Waygood |
Out of interest, when you say "the author of Counter opted to keep fromkeys and have it throw an exception rather than just remove the method" -- what would be the way to "remove a method" from a subclass in Python? I'm not sure I've ever seen it done, except maybe through monkey-patching a class after it's been defined, or by using a metaclass.
|
|
Sep 1, 2021 at 11:04 | comment | added | Alex Waygood |
Thank you, this is great. Your discussion of the way classes relate to their metaclasses, in particular, is fascinating. I was aware that __init__ was, strictly speaking, not a constructor, but you're quite right to correct me, since that wasn't clear in my question.
|
|
Sep 1, 2021 at 3:08 | history | edited | Chris Bouchard | CC BY-SA 4.0 |
Move aside to footnote
|
Sep 1, 2021 at 3:03 | history | edited | Chris Bouchard | CC BY-SA 4.0 |
Link to object.__new__ in the Python docs
|
Sep 1, 2021 at 2:55 | history | edited | Chris Bouchard | CC BY-SA 4.0 |
Fix one more missed "class method" to "static method" when discussing __new__
|
Sep 1, 2021 at 2:50 | history | edited | Chris Bouchard | CC BY-SA 4.0 |
Mention behavioral typing
|
S Sep 1, 2021 at 2:34 | review | First answers | |||
Sep 1, 2021 at 3:11 | |||||
S Sep 1, 2021 at 2:34 | history | answered | Chris Bouchard | CC BY-SA 4.0 |