On 2017-06-23, Gregory Ewing <greg.ew...@canterbury.ac.nz> wrote: > Steve D'Aprano wrote: >> There are a very few exceptions to this rule of thumb, such as >> opening connections to databases or files or similar. > > Another way to handle that is to have the connection method > return another object that has the methods that should only be > called for active connections. That way it's not possible to do > things out of sequence.
It's like a bidirectional iterator in C++, except in reverse it's random access. An iterator that can't easily be modeled with a generator in Python is going to feel awkward. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list