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

actually we can do something like this:

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


cheers..

>>> 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?

Python does have a hash(object) function, or do you mean something like jlm699 mentioned?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.