Skip to main content

Advanced tools for callable objects in Python.

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

Contributors Forks Stargazers Issues MIT License LinkedIn

Python Callabletools

Advanced tools for callable objects in Python.

Changelog · Report Bug · Request Feature

About The Project

Provides advanced tools for callable objects in Python 3.x.

Built With

  • python-shield

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

Does not require any prerequisites.

Installation

  1. Clone the repo
git clone https://github.com/TahsinCr/python-callabletools.git
  1. Install PIP packages
pip install callabletools

Usage

Let's try to retrieve a callable object's arguments, argument count, return result, and the arguments with their given values.

from callabletools import (
    get_arguments, get_argument_length, get_return_argument, get_argument_values
)

def item_to_string(key1:str, key2, start:str='-', *keys, sep:str=', ', **items:int) -> str:
    items = [f'{k}:{v}' for k, v in items]
    return start + sep.join([key1, key2, *keys, items])

func_args = ['test1', 'test2', '--', 'test3']
func_kwargs = {
    'ex' : 'test4'
}

arguments = get_arguments(item_to_string)
print("FuncArgs:", *arguments, sep='\n', end='\n\n')

print("FuncArgLength: {}".format(get_argument_length(item_to_string)), end='\n\n')

print("FuncReturnArg: \n{}".format(get_return_argument(item_to_string)), end='\n\n')

print(
    "FuncArgValues:", 
    *get_argument_values(arguments, func_args, func_kwargs), 
    sep='\n', end='\n\n'
)

Output

FuncArgs:
Argument(name: key1, type: <class 'str'>, default: Ellipsis, argtype: ARG)
Argument(name: key2, type: typing.Any, default: Ellipsis, argtype: ARG)
Argument(name: start, type: <class 'str'>, default: Ellipsis, argtype: ARG)
Argument(name: keys, type: typing.Any, default: Ellipsis, argtype: ARGS)
Argument(name: sep, type: <class 'str'>, default: ', ', argtype: ARG)
Argument(name: items, type: <class 'int'>, default: Ellipsis, argtype: KWARGS)

FuncArgLength: 6

FuncReturnArg: 
Argument(name: return, type: <class 'str'>, default: Ellipsis, argtype: RETURN)

FuncArgValues:
ArgumentValue(name: key1, type: <class 'str'>, default: Ellipsis, argtype: ARG, value: 'test1')
ArgumentValue(name: key2, type: typing.Any, default: Ellipsis, argtype: ARG, value: 'test2')
ArgumentValue(name: start, type: <class 'str'>, default: Ellipsis, argtype: ARG, value: '--')
ArgumentValue(name: keys, type: typing.Any, default: Ellipsis, argtype: ARGS, value: ['test3'])
ArgumentValue(name: sep, type: <class 'str'>, default: ', ', argtype: ARG, value: ', ')
ArgumentValue(name: items, type: <class 'int'>, default: Ellipsis, argtype: KWARGS, value: {'ex': 'test4'})

For more examples, please refer to the Documentation


License

Distributed under the MIT License. See LICENSE for more information.


Contact

Tahsin Çirkin - @TahsinCrs - TahsinCr@outlook.com

Project: TahsinCr/python-callabletools

Project details


Release history Release notifications | RSS feed

This version

1.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

callabletools-1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

callabletools-1.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file callabletools-1.1.tar.gz.

File metadata

  • Download URL: callabletools-1.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for callabletools-1.1.tar.gz
Algorithm Hash digest
SHA256 151b185a5bc6872ae110d551acda233063791dc3dd7372b249e7966124ad7908
MD5 bc3b777adfc8d175201d855eb6e4877b
BLAKE2b-256 e9e37ed9ad91f9a2adcfc12067400d8cc2ed75767107daeb1eda2d1d0d8faac8

See more details on using hashes here.

File details

Details for the file callabletools-1.1-py3-none-any.whl.

File metadata

  • Download URL: callabletools-1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for callabletools-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 19cbaa6b701f243c0b32447099c3f99d12d0b7d02024cf2ed91874999ea4544a
MD5 926d6958a176bfd60dc30f1d738cb8af
BLAKE2b-256 56b82e75e15bfe4ab6c34b28a847b650780c038a025ec9f2612f14a0ab70d915

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