3 ms·
The syntax seems very similar to Lisp's with-open-file macro.
by adharmad 14y ago
The syntax seems very similar to Lisp's with-open-file macro.
- adaszko 14y agoSince you can write your own "context managers," the with statement analogue from Lisp world would rather be unwind-protect.
- ufo 14y agoYes, basically the only difference is that Python's with operates over a context management protocol involving some `__magic__` methods so it can work with other things in addition to files.
- masklinn 14y agoYou can also do that in common-lisp by using the special form `with-open-file` is built upon: unwind-protect[0]. `with-open-file` is just a macro over it, specialized for files handling. [0] http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/speope_unwind-protect.html http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec...