On Thu, 2007-06-21 at 14:26 -0600, Anthony Tuininga wrote: > On 6/21/07, Carsten Haese <[EMAIL PROTECTED]> wrote: > > with api.connect(dbname) as conn: > > with conn.cursor() as cur: > > cur.execute(stmt) > > That's interesting but is it of much use? Connections and cursors > close themselves when they go out of scope. I rarely use > cursor.close() or connection.close() for that reason.
True, but you're at the mercy of when and how that happens. Sometimes you need to be certain that the resources are deallocated exactly when you need them to be deallocated. I don't know if any of my users make use of this with-block feature, but it's out there and documented, so I can't just take it away or replace the semantics of what happens when a connection object controls a with block. For what it's worth, I brought up the above use case back in September 2006, and the response was somewhere between indifferent and positive. Nobody said it was a terrible idea, so I implemented it. Is your transaction-controlling implementation of connection.__enter__/__exit__ already released, i.e. is it too late to get you to change the API to this feature? > Good question on the nested transaction stuff. That might prove useful > -- but its also considerably more complicated than what I was > suggesting.... :-) Of course, but it couldn't hurt to think about it for future extensibility. Then again, it was mostly an academic questions since Informix doesn't support nested transactions ;) -- Carsten Haese http://informixdb.sourceforge.net _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig