Dictionary to tuple
bruno modulix
onurb at xiludom.gro
Wed Jun 29 04:29:56 EDT 2005
Erik Max Francis wrote:
> bruno modulix wrote:
>
>> Err... don't you spot any useless code here ?-)
>>
>> (tip: dict.items() already returns a list of (k,v) tuples...)
>
> But it doesn't return a tuple of them. Which is what the tuple call
> there does.
Of course, but the list-to-tuple conversion is not the point here. The
useless part might be more obvious in this snippet:
my_list = [(1, 'one'), (2, 'two'), (3, 'three')]
my_tup = tuple([(k, v) for k, v in my_list])
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"
More information about the Python-list
mailing list