Skip to main content

Lambda with math operators support

Project description

Install

pip3 install pro_lambda

Documentation

You can find documentation here

Description

pro_lambda make it possible to modify your functions with standart mathematical and logical operators:

from pro_lambda import pro_lambda

some = pro_lambda(lambda : 1)
other = some + 1
# then we call result as if it was (lambda: 1)() + 1
assert other() == 2

some = pro_lambda(lambda x, y: x+y)
other = some + 1
# here we pass some arguments
assert other(1, 2) == 4

# we can also use another function on the right side
other = some + (lambda z, y: z - y)
assert other(1, y = 2, z = 3) == 4

It also supports async functions:

import asyncio
from pro_lambda import pro_lambda


async def main():

    async def _some(x):
        await asyncio.sleep(0.3)
        return x

    _save = _some
    some = pro_lambda(_some)
    other = some + (lambda: 1)
    assert some.is_async
    assert await other(1) == 2

    some = pro_lambda(lambda : 1)
    other = some + _some

    assert other.is_async
    assert await other(x=1) == 2

    some = pro_lambda(_some)
    other = some + _some
    assert other.is_async
    assert await other(x=1) == 2

    other = some == 1

    assert other.is_logical
    assert await other(1)
    assert not await other(2)

asyncio.run(main())

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

pro_lambda-0.1.8.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file pro_lambda-0.1.8.tar.gz.

File metadata

  • Download URL: pro_lambda-0.1.8.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.1

File hashes

Hashes for pro_lambda-0.1.8.tar.gz
Algorithm Hash digest
SHA256 6dfc48814429b2b6186e036e25a591350be28f0cab2434a05d45aeba64cb7bdb
MD5 ef944e9304a6ae5898878bfdf00a4a8b
BLAKE2b-256 f76669b0248e454913669ab8d70bd4ca9e63e124a546c40acd326211e8245c57

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