Skip to main content
https://travis-ci.com/filwaitman/pyrecursive.svg?branch=master https://codecov.io/gh/filwaitman/pyrecursive/branch/master/graph/badge.svg

pyrecursive

Have you ever needed to transform a whatever python object in depth? So this one is for you. =]

Installation:

pip install pyrecursive

Usage:

from pyrecursive import pyrecursive

def double(obj):
    return x * 2

pyrecursive(42, double)
# result: 84

pyrecursive([1, 2, 3, [4, 5, [6], 7], 8, 9, 'x'], double)
# result: [2, 4, 6, [8, 10, [12], 14], 16, 18, 'xx']

pyrecursive({'hamster': [1, 2, 3, {'test': 42}]}, double)
# result: {'hamster': [2, 4, 6, {'test': 84}]}

# In order to transform dict keys in depth: set transform_dict_keys variable to True (default: False).
pyrecursive({'hamster': [1, 2, 3, {'test': 42}]}, double, transform_dict_keys=True)
# result: {'hamsterhamster': [2, 4, 6, {'testtest': 84}]}

# In order not to transform dict values in depth: set transform_dict_values variable to False (default: True).
pyrecursive({'hamster': [1, 2, 3, {'test': 42}]}, double, transform_dict_values=False)
# result: {'hamster': [2, 4, 6, {'test': 42}]}

# In order to define custom rules for each object type in depth: set custom_rules variable.
pyrecursive([1, 2, 3, 'banana'], double, custom_rules={int: lambda x: x * 5})
# result: [5, 10, 15, 'bananabanana'] (multiplied by 5 when int, multiplied by 2 otherwise)

Contribute

Did you think in some interesting feature, or have you found a bug? Please let me know!

Of course you can also download the project and send me some pull requests. Please keep in mind that (1) we do follow pep8, (2) our line-length is 120 chars and (3) your changes must be compatible with Python 2.7 and Python 3.6+.

You can send your suggestions by opening issues.

You can contact me directly as well. Take a look at my contact information at http://filwaitman.github.io/ (email is preferred rather than mobile phone).

Metadata

Release files for pyrecursive 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyrecursive 0.0.2
File Size Uploaded Provenance
pyrecursive-0.0.2.tar.gz 4.2 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for pyrecursive 0.0.2
File Interpreter ABI Platform
pyrecursive-0.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / pyrecursive-0.0.2.tar.gz

Download URL pyrecursive-0.0.2.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9697c6c6782a34dd665057ad4f38036406bdd7cc75e7aa83cecb53c28bd99c79
BLAKE2b-256 checksum
How to use checksums
6ee32a9cffc9e45c6739232ddd24e179b1e21e36c1a96738ca7e1daf00879f57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

Release files / pyrecursive-0.0.2-py3-none-any.whl

Download URL pyrecursive-0.0.2-py3-none-any.whl
Size 3.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46f8cb6acbc92be40037c3212104bce5c041b32874cf421ff9d45f2b3ad0f2e9
BLAKE2b-256 checksum
How to use checksums
a5ea3b4bc33c95d1d7387fc7224b0e7c86a6d1db499b280ea7a3d1f57c763607
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.3.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.6.9

Security for pyrecursive 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page