Re: [Tutor] TypeError: dict objects are unhashable

2009-03-16 Thread A.T.Hofkamp
Lie Ryan wrote: Emile van Sebille wrote: Mark Tolonen wrote: [dict(n) for n in set(tuple(n.items()) for n in l1)] Anyone know if the ordered items for two different dicts where dicta == dictb is guaranteed the same? I know the ordering is unspecified but you can depend on the sequence of k

Re: [Tutor] TypeError: dict objects are unhashable

2009-03-15 Thread Lie Ryan
Emile van Sebille wrote: Mark Tolonen wrote: [dict(n) for n in set(tuple(n.items()) for n in l1)] Anyone know if the ordered items for two different dicts where dicta == dictb is guaranteed the same? I know the ordering is unspecified but you can depend on the sequence of keys matching data

Re: [Tutor] TypeError: dict objects are unhashable

2009-03-14 Thread Emile van Sebille
Mark Tolonen wrote: [dict(n) for n in set(tuple(n.items()) for n in l1)] Anyone know if the ordered items for two different dicts where dicta == dictb is guaranteed the same? I know the ordering is unspecified but you can depend on the sequence of keys matching data and I think it'll also m

Re: [Tutor] TypeError: dict objects are unhashable

2009-03-14 Thread Mark Tolonen
wrote in message news:16014207.1237036582618.javamail.r...@ps26... hi, i have a list which contains duplicate dictionaries. how do i extract the unique items out? l1 = [{'a': 'ddd'}, {'a': 'ddd'}, {'b': 'eee'}, {'c': 'ggg'}] set(l1) TypeError: dict objects are unhashable but, {'a': 'ddd'}

[Tutor] TypeError: dict objects are unhashable

2009-03-14 Thread qsqgeekyog...@tiscali.co.uk
hi, i have a list which contains duplicate dictionaries. how do i extract the unique items out? l1 = [{'a': 'ddd'}, {'a': 'ddd'}, {'b': 'eee'}, {'c': 'ggg'}] set(l1) TypeError: dict objects are unhashable but, >>> {'a': 'ddd'} == {'a': 'ddd'} True >>> david Fancy a job? - http://www.tiscal

Re: [Tutor] TypeError: dict objects are unhashable

2006-03-24 Thread Alan Gauld
Ben, Others have addressed the cause of the error, but... > accounts = {} > UserCursor.execute(sqlstr) > rows = UserCursor.fetchall() > UserConn.commit() > for row in rows: >U = row['User'] >P = row['Password'] >InnerDict = {} >

Re: [Tutor] TypeError: dict objects are unhashable

2006-03-24 Thread Hugo González Monteverde
Ben Vinger wrote: > But I get: > TypeError: dict objects are unhashable > Unfortunately, I just can't see what I'm doing wrong > InnerDict = {} InnerDict[U] = P accounts[InnerDict] = U Your logic is not right somewhere around this. I do not have a lot of c

Re: [Tutor] TypeError: dict objects are unhashable

2006-03-24 Thread Tim Golden
[Ben Vinger] | I want to create a dictionary (from SQL usernames) of | the format: | accounts = { | ('psmit', '123456'): 'psmit', | ('rmatt', 'mypass'): 'rmatt', | } Although possible, this structure looks a little topsy-turvy: you're keying the dictionary on the username

Re: [Tutor] TypeError: dict objects are unhashable

2006-03-24 Thread Kent Johnson
Ben Vinger wrote: > Hello > > I want to create a dictionary (from SQL usernames) of > the format: > accounts = { > ('psmit', '123456'): 'psmit', > ('rmatt', 'mypass'): 'rmatt', > } > > So I have: > accounts = {} > UserCursor.execute(sqlstr) > rows = UserC

[Tutor] TypeError: dict objects are unhashable

2006-03-24 Thread Ben Vinger
Hello I want to create a dictionary (from SQL usernames) of the format: accounts = { ('psmit', '123456'): 'psmit', ('rmatt', 'mypass'): 'rmatt', } So I have: accounts = {} UserCursor.execute(sqlstr) rows = UserCursor.fetchall() UserConn.commit()