3 ms·
I think you are looking for the "with" statement! The feature you describe is already there. And it works with objects, so it's reusable, extendable and exchang
by erikb 14y ago
I think you are looking for the "with" statement! The feature you describe is already there. And it works with objects, so it's reusable, extendable and exchangeable if needed.
http://effbot.org/zone/python-with-statement.htm http://effbot.org/zone/python-with-statement.htm
- deleted 14y ago[deleted]
- masklinn 14y agoNo, context management is only a small subset of what you can do with condition (and does not involve restart), and also implies stack unwinding (as do exceptions) amongst other things. To TFAA: to talk about conditions but not use lisp syntax, you could have used Smalltalk (the other language with conditions and restarts)
- erikb 14y agoWe are not talking "condition" from Lisp here, but the blog post that is linked to this thread. And what the author is doing is asking for a "with" statement without knowing that the feature is already there. "condition" might be a powerful feature and I might even like it myself, but the post doesn't show the power of "condition" to Pythoners, because the feature used in the example already exists in the core language.
- masklinn 14y ago> We are not talking "condition" from Lisp here Of course we are. > And what the author is doing is asking for a "with" statement No, he most definitely is not, a with statement (or Common Lisp's version, `unwind-protect`) does not provide resuming, only restoring a previously-stored context. > the post doesn't show the power of "condition" to Pythoners, because the feature used in the example already exists in the core language. You should try reading the post again rather than stop at the first paragraph, because you're wrong.