Argument classes 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
Python ArgumentSignature
Argument classes for callable objects in Python.
About The Project
Provides easy-to-use argument features for Python 3.x.
Built With
Getting Started
To get a local copy up and running follow these simple example steps.
Prerequisites
Does not require any prerequisites
Installation
- Clone the repo
git clone https://github.com/TahsinCr/python-argumentsignature.git
- Install PIP packages
pip install argumentsignature
Usage
Can store the arguments and values of callable objects.
from argumentsignature import Argument, ArgumentValue, ARG, ARGS, KWARGS
def item_to_string(key1:str, key2:str, *keys:str, **items:int):
itmes = [f'{k}:{v}' for k, v in items]
return ", ".join([key1, key2, *keys, itmes])
arg_items = item_to_string.__annotations__.items()
code = item_to_string.__code__
arg_defaults = item_to_string.__kwdefaults__ or {}
names = code.co_varnames
arg_keys = names[:code.co_argcount]
kwarg_keys = list(arg_defaults.keys())
is_args = True
arguments:list[Argument] = []
for arg_name, arg_type in arg_items:
if arg_name in arg_keys:
arguments.append(Argument(
name = arg_name,
type = arg_type,
argtype = ARG
))
elif arg_name in kwarg_keys:
arguments.append(Argument(
name = arg_name,
type = arg_type,
default = arg_defaults[arg_name],
argtype = ARG
))
elif arg_name == 'return':
continue
else:
arguments.append(Argument(
name = arg_name,
type = arg_type,
argtype = ARGS if is_args else KWARGS
))
is_args = False
print("\n\n".join([str(x) for x in arguments]))
Output
Argument(name: key1, type: <class 'str'>, default: Ellipsis, argtype: ARG)
Argument(name: key2, type: <class 'str'>, default: Ellipsis, argtype: ARG)
Argument(name: keys, type: <class 'str'>, default: Ellipsis, argtype: ARGS)
Argument(name: items, type: <class 'int'>, default: Ellipsis, argtype: KWARGS)
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-argumentsignature
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file argumentsignature-1.0.2.tar.gz.
File metadata
- Download URL: argumentsignature-1.0.2.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8b560b047fb882609ea688dbefd5d033bc86a8fe84054e501081b70a2cc2c84
|
|
| MD5 |
130724657f3b8e12dfd6b3da95b8bcc0
|
|
| BLAKE2b-256 |
ecf5230472bc12ce8b5be24a98d763ac547f837b2a6ad1d7c3cf04154ec475d6
|
File details
Details for the file argumentsignature-1.0.2-py3-none-any.whl.
File metadata
- Download URL: argumentsignature-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2eece4c37e2a664ba1cdce9418a9f4db843c40f13ac4b96f2070de69504e2c16
|
|
| MD5 |
7b2359441a7699d73e4301d4ff239de8
|
|
| BLAKE2b-256 |
ac00a06847938883ff0f09cf4dd59a6976e3b6b2f504578c52a373b95e69d6ed
|