[Tutor] TypeError: dict objects are unhashable

Ben Vinger benvinger at yahoo.co.uk
Fri Mar 24 17:14:25 CET 2006


I want to create a dictionary (from SQL usernames) of
the format:
      accounts = {
      ('psmit', '123456'): 'psmit',
      ('rmatt', 'mypass'): 'rmatt',

So I have:
      accounts = {}
      rows = UserCursor.fetchall()
      for row in rows:
            U = row['User']
            P = row['Password']
            InnerDict = {}
            InnerDict[U] = P
            accounts[InnerDict] = U

But I get:
TypeError: dict objects are unhashable
Unfortunately, I just can't see what I'm doing wrong


NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/

More information about the Tutor mailing list