Skip to main content

inputs for functions

Project description

Overview

The funcinputs project holds the class FuncInput. The objects of this class represent the entire input that can be passed to a function when the function is called. Each FuncInput object has a list of positional arguments (the property is called args) and a dict of keyword arguments (the property is called kwargs). One can do everything with a FuncInput object that can be done with a list or a dict e.g. indexers, appending, or updating.

Installation

To install funcinputs, you can use pip. Open your terminal and run:

pip install funcinputs

Usage

Once funcinputs is installed, you can use it as follows:

from funcinputs import FuncInput

x = FuncInput(args=[9, "foo"], kwargs={"bar":12.75})
print(x) # FuncInput(args=[9, 'foo'], kwargs={'bar': 12.75})
x += FuncInput(args=[2], kwargs={"baz":"spam"})
print(x) # FuncInput(args=[9, 'foo', 2], kwargs={'bar': 12.75, 'baz': 'spam'})
x.append(19)
print(x) # FuncInput(args=[9, 'foo', 2, 19], kwargs={'bar': 12.75, 'baz': 'spam'})

Features

The class FuncInput combines the features of list and dict:

  • Properties:

    • args: represents positional arguments in the shape of a list

    • kwargs: represents the keyword-arguments as a dict (the keys must be limited to the type str)

  • Methods:

    • append: Appends to args

    • clear_all: Combines clear_args and clear_kwargs

    • clear_args: Clears args

    • clear_kwargs: Clears kwargs

    • copy: Makes a copy

    • count: Counts in args

    • exec: Executes a function and returns the result

    • extend: Extends args

    • get: Gets value from kwargs

    • index: Gets index from args

    • insert: Inserts into args

    • items: Returns kwargs.items() converted to a list

    • keys: Returns kwargs.keys() converted to a list

    • pop: Pops value in kwargs if the key is of the type str, otherwise args

    • popitem: Pops item in kwargs

    • remove: Removes from args

    • reverse: Reverses args

    • setdefault: Sets default for kwargs

    • sort: Sorts args

    • update: Updates kwargs

    • values: Returns kwargs.values() converted to a list

  • Other Features:

    • addition: Creates a FuncInput object from two other objects. The property args and the property kwargs are each joined together

    • indexing: If the key is of the type str then kwargs is altered in the normal way, otherwise args

License

This project is licensed under the MIT License.

Credits

Thank you for using funcinputs!

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

funcinputs-1.1.1.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

funcinputs-1.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file funcinputs-1.1.1.tar.gz.

File metadata

  • Download URL: funcinputs-1.1.1.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for funcinputs-1.1.1.tar.gz
Algorithm Hash digest
SHA256 0e9d450e5dc9246bc8183733f55620c6fc253c5f224893a63bdeae88a6399649
MD5 be248a00e800ad3a5ac50a91a6300639
BLAKE2b-256 481eea3a7a5c92fd0555852be69efa4f57b0feaebf4cda13b3052cb5c1f720ea

See more details on using hashes here.

File details

Details for the file funcinputs-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: funcinputs-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for funcinputs-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f8e219101c687ad8eba70f61cc6cb74233ae44066ea81f06ded8d0f529a72c20
MD5 7599a71d6c20c4ebc8aec070dc0e7cbe
BLAKE2b-256 b6d617b36629f2344e8ac548639d58b4963486f6aaabbe1b8b953c4eec4fc392

See more details on using hashes here.

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