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
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
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
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'}
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
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 = {}
>
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
[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
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
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()
10 matches
Mail list logo