News for hackers. Stuff that matters.
Re:Python goto implemented with system trace function (2017) by DSingularity on Tuesday May 05, 2020 @07:09AM (#23078711)
So cute. What are some use-cases for these reflective features?
Re:Python goto implemented with system trace function (2017) by captainmuon on Tuesday May 05, 2020 @08:25AM (#23079227)
I once implemented the "command pattern" in order to have undo in my app. Basically you have to ensure that you only modify your model from command objects, and never directly from UI callbacks. To ensure this, I created a decorator that walked the stack, and asserted that the call originated in a subclass of `Command`. Then I wrapped all setters on the model with this decorator. This was really helpful during development for weeding out cases where Undo didn't work correctly. In the release, you could disable the check so there would be no performance penalty.
Re:Python goto implemented with system trace function (2017) by oefrha on Tuesday May 05, 2020 @07:36AM (#23078901)
One obvious use case invoked all the time: tracebacks are generated through introspection.

https://github.com/python/cpython/blob/3.8/Lib/traceback.py

Re:Python goto implemented with system trace function (2017) by riazrizvi on Tuesday May 05, 2020 @09:25AM (#23079776)
Prototyping condensed state machines. Probably not the code you'd leave in the release version, but can provide an elegant form of experimentation.
Re:Python goto implemented with system trace function (2017) by amelius on Tuesday May 05, 2020 @07:18AM (#23078765)
Transpiled code?