Paul Rubin wrote:
> Yves Glodt <[EMAIL PROTECTED]> writes:
>> that means I can neither have a dictionary with 2 identical keys but
>> different values...?
>
> No.
>
>> I would need e.g. this:
>> (a list of ports and protocols, to be treated later in a loop)
>>
>> ports = {'5631': 'udp', '5632': 'tcp', '3389': 'tcp', '5900': 'tcp'}
>> #then:
>> for port,protocol in ports.iteritems():
>> ________print port,protocol
>> ________#do more stuff
>>
>> What would be the appropriate pythonic way of doing this?
>
> ports = [('5631', 'udp'),
> ('5632': 'tcp'),
> ('3389': 'tcp'),
> ('5900': 'tcp')]
>
> for port,protocol in ports:
> print port, protocol # ...
>
> You'd append with
>
> ports.append(('2345', 'tcp'))
>
> note the double set of parentheses since you're appending a tuple.
Tim, Paul, I love you guys !
Thanks a lot
--
http://mail.python.org/mailman/listinfo/python-list