Skip to main content

A package to extract your nested functions!

Project description

nested

Extract your nested functions!

Installation

    pip install nestd

Usage

from nestd import nested, get_all_nested


def dummy_function():
    test_variable = "hello, world"
    def inner_function():
        nonlocal test_variable
        return test_variable


def dummy_function_with_two_inner_functions():
    test_variable = "hello, world"
    test_array = [1, 2, 3]
    def inner_function():
        nonlocal test_variable
        return test_variable

    def inner_function_2():
        nonlocal test_array
        return test_array[1:]


def test_nested_function():
    inner_function = nested(dummy_function, "inner_function", test_variable="hello" )
    assert "hello" == inner_function()

def test_2_nested_functions():
    all_inner_functions = get_all_nested(dummy_function_with_two_inner_functions, "hello_world", [1,2])
    inner_function, inner_function_2 = all_inner_functions

    assert inner_function[0] == "inner_function"
    assert inner_function[1]() == "hello_world"

    assert inner_function_2[0] == "inner_function_2"
    assert inner_function_2[1]() == [2]

Contributor Guidelines

Feel free to open an issue for any clarification or for any suggestions.

To Develop Locally

  1. poetry install to install the dependencies
  2. pytest tests to run the tests

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

nestd-0.2.1.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

nestd-0.2.1-py3-none-any.whl (2.7 kB view hashes)

Uploaded 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