Skip to main content

Python utility functions for cleaner, more readable code

Project description

funx

PyPI version License: MIT

The main reason why this library was created is to:

use

from funx import isinstances


def add(num1: int, num2: int) -> int:
    if isinstances(num1, num2, datatype=int):  # 41 char
        return num1 + num2
    raise TypeError("invalid arguments types")


print(add(3, 7))

in place of

def add(num1: int, num2: int) -> int:
    if isinstance(num1, int) and isinstance(num2, int):  # 51 char
        return num1 + num2
    raise TypeError("invalid arguments types")


print(add(3, 7))

and

from funx import isinstances


def fun(name: str, age: int) -> None:
    if isinstances(name, age, datatype=(str, int)):  # 47 char
        print(f"your name is {name} and your age is {age}")
        return
    raise TypeError("invalid arguments types")


fun("mohamed", 23)

in place of

def fun(name: str, age: int) -> None:
    if isinstance(name, str) and isinstance(age, int):  # 50 char
        print(f"your name is {name} and your age is {age}")
        return
    raise TypeError("invalid arguments types")


fun("mohamed", 23)

but not just this there is other funcs and with a very advanced usage you can see the source code and check all the tests in the main fun.

Installation

You can install funx via pip:

pip install funx

License

This project is licensed under the MIT LICENSE - see the LICENSE for more details.

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

funx-1.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

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

funx-1.1.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file funx-1.1.0.tar.gz.

File metadata

  • Download URL: funx-1.1.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for funx-1.1.0.tar.gz
Algorithm Hash digest
SHA256 81053a22869d8c8e3aa75d67ac8cb6eb0013a853f8ca45557e93cf9d951b5953
MD5 e73e0da0953e39967203d34a6ca6b26b
BLAKE2b-256 904f8b792266c4edc4611957a1210d56bbf67e1b3619130c7df50ee8fe843a01

See more details on using hashes here.

File details

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

File metadata

  • Download URL: funx-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for funx-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f39f887a8321ccae4f2f001a2a80ca108afaee05b3fad01d75fd685c64ea15a5
MD5 b9942b0750e43debbec04dd975e22eec
BLAKE2b-256 a50d8022212f2d098cc70c6c910f05ec78a809f9a007ff64908a0d02e8d163e9

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