Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

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

Release files for callabletools 1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for callabletools 1.1
File Size Uploaded
callabletools-1.1.tar.gz 5.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for callabletools 1.1
File Interpreter ABI Platform
callabletools-1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.6 kB

Release files / callabletools-1.1.tar.gz

Download URL callabletools-1.1.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
151b185a5bc6872ae110d551acda233063791dc3dd7372b249e7966124ad7908
BLAKE2b-256 checksum
How to use checksums
e9e37ed9ad91f9a2adcfc12067400d8cc2ed75767107daeb1eda2d1d0d8faac8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / callabletools-1.1-py3-none-any.whl

Download URL callabletools-1.1-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19cbaa6b701f243c0b32447099c3f99d12d0b7d02024cf2ed91874999ea4544a
BLAKE2b-256 checksum
How to use checksums
56b82e75e15bfe4ab6c34b28a847b650780c038a025ec9f2612f14a0ab70d915
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page