This package implements a class taking keyword arguments from methods and setting them in the init function
Project description
KwargsMeta
KwargsMeta is a Python package that provides a metaclass to automatically handle keyword arguments (kwargs) from methods. This metaclass allows you to set values of keyword arguments from methods in the __init__ method without explicitly specifying them, making your code cleaner and more maintainable.
Features
- Automatically injects keyword arguments into the
__init__method. - Simplifies the initialization of classes with many keyword arguments.
- Reduces boilerplate code.
- Allows to set keyword arguments from methods in the
__init__method.
Installation
You can install KwargsMeta using pip:
pip install likiskwargsmeta
Usage
Here is an example of how to use KwargsMeta:
from likiskwargsmeta import KwargsMeta
class MyClass(metaclass = KwargsMeta):
def __init__(self, a, b = 12):
self.a = a
self.b = b
def method1(self, b = 3, c = 12):
print(f"{b = }, {c = }")
MyClass(1).method1() # will print b = 12, c = 12
MyClass(12, b = 3).method1(c = 1) # will print b = 3, c = 1
MyClass(1, b = None).method1() # will print b = 3, c = 12
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Project details
Release history Release notifications | RSS feed
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 likiskwargsmeta-0.1.0.tar.gz.
File metadata
- Download URL: likiskwargsmeta-0.1.0.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eeba9b9f874fecea8e1421a0fcbad4c30a47b17a7ac9dc0c4624b582be0ca33f
|
|
| MD5 |
a90c47a88189763f9f0539ec3a50e6b9
|
|
| BLAKE2b-256 |
d79d1b9ce7a1f86f285d1dc107eb1247ccc03d9deaa1e3922489c595a3d72995
|
File details
Details for the file likiskwargsmeta-0.1.0-py3-none-any.whl.
File metadata
- Download URL: likiskwargsmeta-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c8a44d0526aec37944e930f0e5a6c0f518e3822fff1fc6c685b391af05c0252b
|
|
| MD5 |
fb995f9b7ee4ba907eccd72c2fff9860
|
|
| BLAKE2b-256 |
13daba0185262aaa9e6fb37e816c4f3a7236e00d265ff932f5324b9d5bfabc38
|