Skip to main content

Enable function chaining for any object

Project description

Enable function chaining for any object.

Contained is a class that can wrap any type and make it possible to do function chaining on that object, much like functional piping.

Any method that is defined on the contained type is possible to call, whether it returns a copy or mutates in place. It is also possible to call operators and any builtin function, without breaking the chain. To get the original variable back out of the Contained, just call it with no args.

ex = ['hello', 'world']
Contained(ex)() == ex  # True

# methods
Contained(['hello']).extend(['world'])() == ex  # True

# operators
Contained(['hello']).add(['world']).contains('hello')()  # True

# builtins
Contained(ex).len().type()()  # <class 'int'>

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

contained-0.0.1-py2.py3-none-any.whl (2.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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