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.
_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to