Plucking (deep) keys/paths safely from python collections has never been easier.
Project description
plucky.pluck enables you to safely extract several-levels deep values by using a concise selector comprised of dictionary-like keys and list-like indices. Wildcards over list items are also supported.
Usage
from plucky import pluck
pluck(obj, 'selector.*.path.2')
Examples
obj = {
'users': [{
'uid': 1234,
'name': {
'first': 'John',
'last': 'Smith',
}
}, {
'uid': 2345,
'name': {
'last': 'Bono'
}
}]
}
pluck(obj, 'users.1.name')
# -> {'last': 'Bono'}
pluck(obj, 'users.*.name.last')
# -> ['Smith', 'Bono']
pluck(obj, 'users.*.name.first')
# -> ['John']
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
plucky-0.1.tar.gz
(3.2 kB
view hashes)
Built Distributions
plucky-0.1-py2.7.egg
(4.0 kB
view hashes)