0

Hi,
Is there a way in python to get multiple values from a dict? In perl we have this syntax:
@values = @hash{@fields}

is there something similar in python?

thanks,
Sam

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by vegaseat
0

actually we can do something like this:

@values = map(lambda field: hash[field], @fields)


cheers..

0
>>> md = {}
>>> md['a'] = [1,2,3,4]
>>> md['h'] = (1,2)
>>> md['t'] = {'first':[9,8,7], 'sec':(1,2,3,4), 'h':'foobar'}
>>> md
{'a': [1, 2, 3, 4], 'h': (1, 2), 't': {'h': 'foobar', 'sec': (1, 2, 3, 4), 'first': [9, 8, 7]}}
>>>

Is that what you mean by multiple values from a dictionary?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.