Skip to main content

Add basic functional methods to standard types

Project description

Sweet Pear library

Sweet pear is a python package which add basic functional member methods to the build in python types (str, tuple, list, range).

I don't find my loved awsmstff function!

If you think that a commonly used function is missing, don't worry. Just open a issue for feature request describing its usage. If your request is accepted, it will be implemented in few days and a new version of this package will be released.

Examples

Usage example:

import sweetpear

(1, 2, 3, 4).map(lambda x: x**2)
["hello", "world"].map('capitalize')

You can also is this property to access member of objects:

import numpy as np
import torch

infos = (np.array([1,2,3]), np.zeros((2,5)), torch.ones((3,4)))
infos.map('shape')

Advanced features like groupby are now easily accessible :)

>>> "Abrakadabra!".groupby(lambda x: x== 'a' or x== "A")
{True: ['A', 'a', 'a', 'a', 'a'], False: ['b', 'r', 'k', 'd', 'b', 'r', '!']}

API

Here is the list of the available functions:

[].map
[].tail
[].drop
[].take
[].firt
[].second
[].concat
[].flatten
[].count
[].groupby
[].filter
[].reject

For more information on a specific method, just type

import sweetpear

help([].groupby)

in your python console.

How does it works

The implementation rely on the python library ForbiddenFruit to patch the built in types and add custom methods. Most of the methods are binding around the awesome cytoolz package.

Project details


Download files

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

Source Distribution

sweet-pear-1.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sweet_pear-1.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file sweet-pear-1.1.0.tar.gz.

File metadata

  • Download URL: sweet-pear-1.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.7

File hashes

Hashes for sweet-pear-1.1.0.tar.gz
Algorithm Hash digest
SHA256 dbfa979dd96ccd51af4e75d4aa48e7518b77767d7dd3297e407d979c94bb4814
MD5 038b51a8a8b56d02ed8ff8b7fd68dbf9
BLAKE2b-256 5607c93852686f19006852d0c1e6c6d4cadb53dbba56f757f293d9a0e42e0e94

See more details on using hashes here.

File details

Details for the file sweet_pear-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: sweet_pear-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.7

File hashes

Hashes for sweet_pear-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 88edb60a8c4bc3bdad247719c949aeed3800f9d4a5a26f4840fcf8972f55550a
MD5 7ae3e4bbb072276d487c43b1751632e0
BLAKE2b-256 3e1dbeeb15c3ec57d7388da5035ae2e4fb4e75a120f6bbb29799240d0baa9984

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page