Skip to main content

forbiddenfluent

This module adds the built-in functions that work on iterables and make them into methods in order to support a fluent programming style. It uses the package forbiddenfruit to do so, thus the name. The package is intended as a classroom teaching tool and talk tool, so likely won't be expanded much. If you like this, see fluentpy and assertpy for more support of this programming style in Python.

Installation

The package is installable via the Python Package Repository:

pip install forbiddenfluent

Examples

>>> import forbiddenfluent
>>> forbiddenfluent.curse()  # Adds methods to built-in objects in-place

>>> [1, 2, 3].map(lambda x: x * 2)
[2, 4, 6]

>>> ["Algeria", "Belgium", "Canada"].map(str.lower).filter(lambda x: len(x) > 6)
["algeria", "belgium"]

>>> [1, 2, 3].sum()
6

>>> (["Algeria", "Belgium", "Canada"]
>>>  .map(str.lower)
>>>  .filter(lambda x: len(x) > 6)
>>> )
["algeria", "belgium"]

>>> forbiddenfluent.reverse()
>>> [1, 2, 3].map(lambda x: x * 2)  ## AttributeError!

Limitations

To keep use of this module simple, each method follows the convention of returning a same-type copy of itself; That is, list.map() returns a list, set.filter() returns a set, and so on. This means a loss of performance benefits that relate to the lazy iteration of normal map(list) and map(set) operations. The author of this package is open to adding this feature in the future, although likely other packages for fluent programming will be a better option.

Metadata

Release files for forbiddenfluent 0.1.1

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

Source distribution (sdist)

Source distribution for forbiddenfluent 0.1.1
File Size Uploaded
forbiddenfluent-0.1.1.tar.gz 2.4 kB Details

Release files / forbiddenfluent-0.1.1.tar.gz

Download URL forbiddenfluent-0.1.1.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
2d4722342c3bd7b6cb9773c41b66f3dcd770240944342a5b8348a4d1c6ac6e70
BLAKE2b-256 checksum
How to use checksums
d68eeb549be96a1cad10025f490550b32264f3d1afd87fc1bfc1519254f8b0cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.5

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1

1 release file

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