On 11 Dec 2012, at 3:59 AM, Teddy Nyambe <[email protected]> wrote: > What am i missing with these statement: > > def getDict(): > return {(o.id:o.name for o in db(db.table).select()} > > or > > def getDict(): > return dict((o.id:o.name for o in db(db.table).select()) > > getting same syntax error for both, whats the correct way of returning a > dictionary? >
IIRC, dict() will take a list of tuples. I'd try: return dict( ( (o.id, o.name) for o in db(db.table).select() ) ) (extra spaces for clarity) --

