4 ms·
Regarding Python3 sample at the end, What if the method y is mutating the object? Then when I just check for existence of y with hasattr, it will mutate the ob
by aladagemre 11y ago
Regarding Python3 sample at the end,
What if the method y is mutating the object? Then when I just check for existence of y with hasattr, it will mutate the object. I wouldn't want that.
- icebraining 11y agoThe reality is that almost any interaction with an object can cause it to mutate itself, since Python allows classes to override just about any operator. For example: "a > 3", "5 in a", "x = a.b", "len(a)", "print a", etc - all of these can cause a to mutate. In the end, you have to trust the code to do the Right Thing, or just not use it.