useful-functions-easier-life


Nameuseful-functions-easier-life JSON
Version 0.14 PyPI version JSON
download
home_pagehttps://github.com/hansalemaos/useful_functions_easier_life
SummaryNamed functions, ignore Exceptions decorator with parameters, multiple functions execution ...
upload_time2023-01-06 15:35:21
maintainer
docs_urlNone
authorJohannes Fischer
requires_python
licenseMIT
keywords functools decorator methods functions
VCS
bugtrack_url
requirements decorator
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
#### Some useful stuff for functions



##### NamedFunction

```python

pip install useful-functions-easier-life

```



```python

    namedfunctiontest = NamedFunction(

        name="myfunction",

        execute_function=execute_several_functions_insideout(

            lambda x: x * 100, lambda x: x / 10, lambda x: x * 5, lambda x: x + 1000

        ),

        name_function=lambda: "This is my function",

        str_prefix="Surprise",

        print_before_execution="My function\n",

        str_suffix="Let's go!",

        ljust_prefix=10,

        rjust_prefix=30,

        ljust_suffix=20,

        rjust_suffix=10,

    )





    namedfunctiontest

    Out[3]:                     Surprise  This is my function Let's go!



    #Without namedfunction:

    #ca2

    #Out[7]: <function __main__.execute_several_functions_insideout.<locals>.deco(f)>



    namedfunctiontest(5)

    My function

    Out[6]: 50250.0

```



##### ignore_exceptions_decorator



```python

    from random import choice



    @ignore_exceptions_decorator(print_exception=True, exception_value=False, disable=False)

    def testest(number):

        if number == 0:

            return True

        elif number == 1:

            print(number / 0)

        return True





    testex = [testest(choice([0, 1])) for x in range(10)]





    division by zero

    division by zero

    testex

    Out[3]: [True, True, False, True, False, True, True, True, True, True]



    #https://stackoverflow.com/questions/5929107/decorators-with-parameters



    #Blueprint for other useful stuff

```



##### execute_several_functions_insideout



```python

    ca2 = execute_several_functions_insideout(

        lambda x: x * 100, lambda x: x / 10, lambda x: x * 5, lambda x: x + 1000

    )



    ca2(5)

    Out[6]: 50250.0



    (1000+5) * 5 / 10 * 100

    Out[18]: 50250.0

```



##### execute_several_functions_one_after_another



```python

    allfunctions=lambda x: (x, isinstance(x,str)),lambda x: str(x) + '-1000', lambda x:x*5, lambda x: isinstance(x,str)

    ca=execute_several_functions_one_after_another(allfunctions)





    ca(101)

    Out[4]: [(101, False), '101-1000', 505, False]

```



##### ignore_exceptions



```python

    testex = [ignore_exceptions(divmod, 50, choice([0, 1]),exception_value=(0,0)) for x in range(10)]



    testex

    Out[7]:

    [(50, 0),

     (0, 0),

     (0, 0),

     (0, 0),

     (50, 0),

     (50, 0),

     (50, 0),

     (50, 0),

     (50, 0),

     (0, 0)]

```


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hansalemaos/useful_functions_easier_life",
    "name": "useful-functions-easier-life",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "functools,decorator,methods,functions",
    "author": "Johannes Fischer",
    "author_email": "<aulasparticularesdealemaosp@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/56/32/60e84ecd23a3f9940dac3183d320c9a618af240a929bd636e401a4a8a9f0/useful_functions_easier_life-0.14.tar.gz",
    "platform": null,
    "description": "\n#### Some useful stuff for functions\n\n\n\n##### NamedFunction\n\n```python\n\npip install useful-functions-easier-life\n\n```\n\n\n\n```python\n\n    namedfunctiontest = NamedFunction(\n\n        name=\"myfunction\",\n\n        execute_function=execute_several_functions_insideout(\n\n            lambda x: x * 100, lambda x: x / 10, lambda x: x * 5, lambda x: x + 1000\n\n        ),\n\n        name_function=lambda: \"This is my function\",\n\n        str_prefix=\"Surprise\",\n\n        print_before_execution=\"My function\\n\",\n\n        str_suffix=\"Let's go!\",\n\n        ljust_prefix=10,\n\n        rjust_prefix=30,\n\n        ljust_suffix=20,\n\n        rjust_suffix=10,\n\n    )\n\n\n\n\n\n    namedfunctiontest\n\n    Out[3]:                     Surprise  This is my function Let's go!\n\n\n\n    #Without namedfunction:\n\n    #ca2\n\n    #Out[7]: <function __main__.execute_several_functions_insideout.<locals>.deco(f)>\n\n\n\n    namedfunctiontest(5)\n\n    My function\n\n    Out[6]: 50250.0\n\n```\n\n\n\n##### ignore_exceptions_decorator\n\n\n\n```python\n\n    from random import choice\n\n\n\n    @ignore_exceptions_decorator(print_exception=True, exception_value=False, disable=False)\n\n    def testest(number):\n\n        if number == 0:\n\n            return True\n\n        elif number == 1:\n\n            print(number / 0)\n\n        return True\n\n\n\n\n\n    testex = [testest(choice([0, 1])) for x in range(10)]\n\n\n\n\n\n    division by zero\n\n    division by zero\n\n    testex\n\n    Out[3]: [True, True, False, True, False, True, True, True, True, True]\n\n\n\n    #https://stackoverflow.com/questions/5929107/decorators-with-parameters\n\n\n\n    #Blueprint for other useful stuff\n\n```\n\n\n\n##### execute_several_functions_insideout\n\n\n\n```python\n\n    ca2 = execute_several_functions_insideout(\n\n        lambda x: x * 100, lambda x: x / 10, lambda x: x * 5, lambda x: x + 1000\n\n    )\n\n\n\n    ca2(5)\n\n    Out[6]: 50250.0\n\n\n\n    (1000+5) * 5 / 10 * 100\n\n    Out[18]: 50250.0\n\n```\n\n\n\n##### execute_several_functions_one_after_another\n\n\n\n```python\n\n    allfunctions=lambda x: (x, isinstance(x,str)),lambda x: str(x) + '-1000', lambda x:x*5, lambda x: isinstance(x,str)\n\n    ca=execute_several_functions_one_after_another(allfunctions)\n\n\n\n\n\n    ca(101)\n\n    Out[4]: [(101, False), '101-1000', 505, False]\n\n```\n\n\n\n##### ignore_exceptions\n\n\n\n```python\n\n    testex = [ignore_exceptions(divmod, 50, choice([0, 1]),exception_value=(0,0)) for x in range(10)]\n\n\n\n    testex\n\n    Out[7]:\n\n    [(50, 0),\n\n     (0, 0),\n\n     (0, 0),\n\n     (0, 0),\n\n     (50, 0),\n\n     (50, 0),\n\n     (50, 0),\n\n     (50, 0),\n\n     (50, 0),\n\n     (0, 0)]\n\n```\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Named functions, ignore Exceptions decorator with parameters, multiple functions execution ...",
    "version": "0.14",
    "project_urls": {
        "Homepage": "https://github.com/hansalemaos/useful_functions_easier_life"
    },
    "split_keywords": [
        "functools",
        "decorator",
        "methods",
        "functions"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "59e8dad5da8ed08f9f6937244ba6546e4dd9d85864e31f59a74ffb6e26921a94",
                "md5": "a623a4e7aa929c458e4600c1d0220d49",
                "sha256": "991a67e240c30828e165c79c9e92dd95588f65d42fe1de0ddcd1c0da6fda1b66"
            },
            "downloads": -1,
            "filename": "useful_functions_easier_life-0.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a623a4e7aa929c458e4600c1d0220d49",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 7242,
            "upload_time": "2023-01-06T15:35:20",
            "upload_time_iso_8601": "2023-01-06T15:35:20.003334Z",
            "url": "https://files.pythonhosted.org/packages/59/e8/dad5da8ed08f9f6937244ba6546e4dd9d85864e31f59a74ffb6e26921a94/useful_functions_easier_life-0.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "563260e84ecd23a3f9940dac3183d320c9a618af240a929bd636e401a4a8a9f0",
                "md5": "cf843f68de3d15e9ef005688cab2fb9f",
                "sha256": "12bfff96590b4fbab16bc26f252a00fe53764d7cf510ad7c62d2c47bc0b0b514"
            },
            "downloads": -1,
            "filename": "useful_functions_easier_life-0.14.tar.gz",
            "has_sig": false,
            "md5_digest": "cf843f68de3d15e9ef005688cab2fb9f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5188,
            "upload_time": "2023-01-06T15:35:21",
            "upload_time_iso_8601": "2023-01-06T15:35:21.559058Z",
            "url": "https://files.pythonhosted.org/packages/56/32/60e84ecd23a3f9940dac3183d320c9a618af240a929bd636e401a4a8a9f0/useful_functions_easier_life-0.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-01-06 15:35:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hansalemaos",
    "github_project": "useful_functions_easier_life",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "decorator",
            "specs": []
        }
    ],
    "lcname": "useful-functions-easier-life"
}
        
Elapsed time: 0.26187s