Metadata-Version: 2.4
Name: pluckit
Version: 0.6.1
Summary: extract values from collection items
Author: Daniel Pepper
License-Expression: MIT
Project-URL: Homepage, https://github.com/dpep/py_pluckit
Project-URL: Issues, https://github.com/dpep/py_pluckit/issues
Project-URL: Changelog, https://github.com/dpep/py_pluckit/blob/main/CHANGES.txt
Keywords: pluck,collections,map,path
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Provides-Extra: native
Requires-Dist: forbiddenfruit; extra == "native"
Dynamic: license-file

pluckit
======
Extract values from collection items.


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


### Usage
```python
from pluckit import pluck

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


# supports arbitrarily deep plucks and function calls
people = [
    { 'name': 'Daniel', 'friends': [ 'Josh', 'Mel' ] },
    { 'name': 'Mel', 'friends': [ 'Daniel', 'Suzy' ] },
]
pluck(people, 'friends[-1].lower[:3]')
> [ 'mel', 'suz' ]



# 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}
```

----
[![Python](https://github.com/dpep/py_pluckit/actions/workflows/python.yml/badge.svg)](https://github.com/dpep/py_pluckit/actions/workflows/python.yml)
[![installs](https://img.shields.io/pypi/dm/pluckit?label=installs)](https://pypi.org/project/pluckit)
