On 10/17/2013 9:06 AM, Barry Warsaw wrote: > There's a fundamental conceptual shift here that's worth exploring more, and > which I think was first identified by RDM. > > Until now, context managers were at their heart (at least IMHO) about managing > "resources". A general resource might be an open file, or it might be a > database transaction, or even the current working directory. Context managers > (as expressed elegantly by the `with` statement) are used to ensure that a > resource acquired for some limited operation is - to Python's best ability - > "released" at the end of that operation, no matter what happens. E.g. the > file is closed even if there's a write error, or the current working directory > is restored to its original location. The conceptual shift exists, as you two have pointed out. But that is mostly because Structured programming and OO have created sufficient conceptual idioms that people have forgotten that all of these idioms are to avoid bare gotos. The real purpose of all such constructs is to manage the instruction pointer, and context managers, while useful for managing "resources" in the abstract, are truly about managing the control flow -- hopefully in understandable ways. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20131017/1810cddb/attachment.html>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4