On Tue, 26 Apr 2022 at 10:05, Greg Ewing <greg.ew...@canterbury.ac.nz> wrote: > > On 23/04/22 5:44 pm, Chris Angelico wrote: > > On Sat, 23 Apr 2022 at 15:32, Larry Hastings <la...@hastings.org> wrote: > >> > >> Still, it's not the intent of my PEP to condone or facilitate > >> monkeypatching. > >> > > > > The only difference is that you call it something > > different. > > To me, monkeypatching means modifying the definition of something > after the fact in a way that it wasn't designed for. > > Here, the modification is fully intended, so it's not monkeypatching.
That's exactly what I mean though: if the only difference between "monkeypatching" and "not monkeypatching" is whether it was intended, then the only difference is what you call it. class Spam: pass def frobnicate(self): print("Hah") Spam.frobnicate = frobnicate Is this monkeypatching? Does it stop being monkeypatching if I put a comment in the Spam class saying "the frobnicate method will be added afterwards"? The ONLY difference here is what you call it. Maybe we shouldn't be scared of mutating mutable objects? > Also, as long as you can only 'continue' a class that was > previously declared 'forward', and only do it once, and can't > use a forward class until it has been continued, it doesn't > make monkeypatching any easier than it currently is. > Yes, and IMO that's an unfortunate loss of generality for very little benefit. You can patch in the dunder and then continue any class, which basically just means you can use this for any monkeypatching you like - all you have to do is fiddle with a bookkeeping directive. You have to remove the "please don't monkey around" sign and then you can monkey around all you like. So what's the value of the sign? (There are other aspects to the proposal, like how it interacts with metaclasses. But for this specific part, I don't see it as beneficial to restrict the feature. For instance, the dunder could effectively mean "next time this class gets continued, run its metaclass", but other than that, continuing any class could be permitted.) ChrisA _______________________________________________ Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-le...@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/ZSF4IT5XOEH2RHN67KSGWW3L6FBADQB4/ Code of Conduct: http://python.org/psf/codeofconduct/