Skip to main content

extract values from collection items

Project description

pluckit
======
Easily extract values from collection items.


### Install
```pip install pluckit```


### Usage
```
from pluckit import pluck

data = [
{'x': 1, 'y': 2},
{'x': 2, 'y': 4},
{'x': 3, 'y': 6},
]
pluck(data, 'x')
> [1, 2, 3]


# use Pluckables for built-in functionality

from pluckit.pluckable import PluckableList

PluckableList([
{'x': 1, 'y': 2},
{'x': 2, 'y': 4},
{'x': 3, 'y': 6},
]).pluck('x')
> [1, 2, 3]


# use the Pluckable mixin to build your own

from pluckit import Pluckable
class MyDict(dict, Pluckable): pass

MyDict({
'home' : {'x' : 1, 'y' : 2},
'work' : {'x' : 3, 'y' : 6},
}).pluck('x')
> {'home' : 1, 'work' : 3}
```

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pluckit, version 0.4.0
Filename, size File type Python version Upload date Hashes
Filename, size pluckit-0.4.0.tar.gz (4.3 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page