Re: lists and dictionaries

2007-07-17 Thread Ladislav Andel
Hi, could you actually help me further? I thought it will quite easy but I've been programming in python just for a month. I need to add extra items in new list. So here is example: I have a list of dictionaries. e.g. [{'index': 0, 'ip_addr': '1.2.3.4', 'server-name':'Asterisk', 'transport': 'ud

Re: lists and dictionaries

2007-07-12 Thread Ladislav Andel
Thank you to all of you guys. It's exactly I was looking for. Lada Bart Ogryczak wrote: > On 12 jul, 04:49, anethema <[EMAIL PROTECTED]> wrote: > >>> li = [ {'index': 0, 'transport': 'udp', 'service_domain': >>> 'dp0.example.com'}, >>> {'index': 1, 'transport': 'udp', 'service_domain

Re: lists and dictionaries

2007-07-12 Thread Ladislav Andel
Thank you to all of you guys. It's exactly I was looking for. > You provide scant information for this task. For example, is the > new list ordered or unordered? Can the list corresponding to the > 'transports' key contain duplicates? > unordered is fine.. I will be storing it in DB from that

Re: lists and dictionaries

2007-07-12 Thread Bart Ogryczak
On 12 jul, 04:49, anethema <[EMAIL PROTECTED]> wrote: > > li = [ {'index': 0, 'transport': 'udp', 'service_domain': > > 'dp0.example.com'}, > > {'index': 1, 'transport': 'udp', 'service_domain': > > 'dp1.example.com'}, > > {'index': 0, 'transport': 'tcp', 'service_domain': > > 'dp0

Re: lists and dictionaries

2007-07-12 Thread Bart Ogryczak
On 11 jul, 21:08, Ladislav Andel <[EMAIL PROTECTED]> wrote: > Hi, > I have a list of dictionaries. > e.g. > [{'index': 0, 'transport': 'udp', 'service_domain': 'dp0.example.com'}, > {'index': 1, 'transport': 'udp', 'service_domain': 'dp1.example.com'}, > {'index': 0, 'transport': 'tcp', 'service_do

Re: lists and dictionaries

2007-07-11 Thread anethema
> li = [ {'index': 0, 'transport': 'udp', 'service_domain': > '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', 'servi

Re: lists and dictionaries

2007-07-11 Thread [EMAIL PROTECTED]
On Jul 11, 12:08 pm, Ladislav Andel <[EMAIL PROTECTED]> wrote: > Hi, > I have a list of dictionaries. > e.g. > [{'index': 0, 'transport': 'udp', 'service_domain': 'dp0.example.com'}, > {'index': 1, 'transport': 'udp', 'service_domain': 'dp1.example.com'}, > {'index': 0, 'transport': 'tcp', 'service

lists and dictionaries

2007-07-11 Thread Ladislav Andel
Hi, I have a list of dictionaries. e.g. [{'index': 0, 'transport': 'udp', 'service_domain': '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_dom

Re: operation complexities of lists and dictionaries

2006-03-29 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > what are the time complexities of inserting / removing / checking if an > element is present in 1) a list and 2) a dictionary? > does anybody know? I assume in the list case, the element you want to operate on is in the middle of the list. In CPyt

Re: operation complexities of lists and dictionaries

2006-03-29 Thread Ben Finney
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > what are the time complexities of inserting / removing / checking if an > element is present in 1) a list and 2) a dictionary? Partly dependent on the implementation, of which there are several for Python (CPython, Jython, PyPy, and others). Which

Re: operation complexities of lists and dictionaries

2006-03-29 Thread Steven D'Aprano
On Wed, 29 Mar 2006 09:38:05 -0800, [EMAIL PROTECTED] wrote: > > hi, > i've just a simple question: > what are the time complexities of inserting / removing / checking if an > element is present in 1) a list and 2) a dictionary? > does anybody know? > thanks No no no, that's not the way to ask t

Re: operation complexities of lists and dictionaries

2006-03-29 Thread Caleb Hattingh
Hi Use the "timeit" module, like so: >>> from timeit import Timer >>> t = Timer('[i for i in range(1)]') # The string is code to execute >>> (for timing) >>> print t.timeit(100) # execute it 100 times and print the result 0.222389936447 I would appreciate it if you could present your resul

operation complexities of lists and dictionaries

2006-03-29 Thread [EMAIL PROTECTED]
hi, i've just a simple question: what are the time complexities of inserting / removing / checking if an element is present in 1) a list and 2) a dictionary? does anybody know? thanks -- http://mail.python.org/mailman/listinfo/python-list