Re: lists and dictionaries
- From: Ladislav Andel <ladaan@xxxxxxxxx>
- Date: Thu, 12 Jul 2007 21:01:00 +0200
Thank you to all of you guys.
It's exactly I was looking for.
You provide scant information for this task. For example, is theunordered is fine.. I will be storing it in DB from that list.
new list ordered or unordered? Can the list corresponding to the
'transports' key contain duplicates?
It should not happen to get 'transports' duplicates in my application.
It's for testing domains where are running SIP servers.
Lada
Bart Ogryczak wrote:
On 12 jul, 04:49, anethema <jefish...@xxxxxxxxx> wrote:
li = [ {'index': 0, 'transport': 'udp', 'service_domain':I like this solution:
'dp0.example.com'},
{'index': 1, 'transport': 'udp', 'service_domain':
'dp1.example.com'},
{'index': 0, 'transport': 'tcp', 'service_domain':
'dp0.example.com'},
{'index': 1, 'transport': 'tcp', 'service_domain':
'dp1.example.com'}]
[{ 'transports' : [d['transport'] for d in li if
d['service_domain'] == dom],
'service_domain': dom,
} for dom in set(d2['service_domain'] for d2 in li)]
merely because it takes one line. Humorously enough, it appears to be
twice as efficient,
Correct me if I´m wrong, that is a O(n**2) solution, to O(n) problem.
.
- References:
- lists and dictionaries
- From: Ladislav Andel
- Re: lists and dictionaries
- From: attn.steven.kuo@xxxxxxxxx
- Re: lists and dictionaries
- From: anethema
- Re: lists and dictionaries
- From: Bart Ogryczak
- lists and dictionaries
- Prev by Date: Re: lists and dictionaries
- Next by Date: Re: PEP 3107 and stronger typing (note: probably a newbie question)
- Previous by thread: Re: lists and dictionaries
- Next by thread: Re: lists and dictionaries
- Index(es):
Relevant Pages
|