2 ms·
> you can update the definition of a class in a running system and update all existing instances of that class Like this? >>> class MyClass: ... att
by progval 4y ago
> you can update the definition of a class in a running system and update all existing instances of that class
Like this?
>>> class MyClass:
... attr = 0
...
>>> my_object = MyClass()
>>> MyClass.attr = 42
>>> my_object.attr
42
>>> MyClass.method = lambda self: self.attr
>>> my_object.method()
42
> When an error occurs you can inspect local variables in any of the stack frames and execute commands in them
What is the difference with https://lukeplant.me.uk/blog/posts/pythons-disappointing-superpowers/#werkzeugs-interactive-debugger https://lukeplant.me.uk/blog/posts/pythons-disappointing-sup... ?
- troutpanda 4y agoTo Lispers, Python's hyperpowers (reflection and dynamic typing) are just regular Lisp business. Lisp's strength lies exactly in how convenient doing metaprogramming is in Lisp. There are probably some subtleties and differences in how powerful both systems are (can't say more, I don't know how powerful python's metaprogramming is), but just know that Lisp has practically no limit in how you can extend the language.
- lispm 4y agoAdding/changing/removing slots & methods. But also adding/removing superclasses -> which causes changes in existing objects. Having functions called when an object changes, etc. That's old in CLOS, end 80s. No wonder if some other dynamic languages by now have similar features.