Carl Banks <[EMAIL PROTECTED]> wrote:

> Perhaps the advent of with blocks will help reduce this error in the
> future.

Indeed, and to encourage its use I think this thread ought to include the 
'with statement' form of the function:

from __future__ import with_statement
from contextlib import closing

def count(self):
    with closing(sqlite.connect(
        self.filename,isolation_level=ISOLATION_LEVEL)) as db:
        with closing(db.cursor()) as cur:
            cur.execute("select count(*) from sessions")
            return cur.fetchone()[0]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to