3 ms·
I recall setting obj.__class__ in Python (kind of the same thing – though without the notion of slots), but I can't recall why that was useful. Hot-reloading i
by ianbicking 11y ago
I recall setting obj.__class__ in Python (kind of the same thing – though without the notion of slots), but I can't recall why that was useful. Hot-reloading is the one case I can think of (one of the things mentioned).
- nostrademons 11y agoIt's a good alternative to the State or Strategy patterns when you only need one per object and virtually all methods are affected. Using the pattern, you'd need to explicitly delegate all calls to the state/strategy object. When you change the class, you're effectively using the type object as the state/strategy object, which makes perfect sense because it already contains all the methods.