Skip to main content

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.

Release files for likiskwargsmeta 0.1.0

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

Source distribution (sdist)

Source distribution for likiskwargsmeta 0.1.0
File Size Uploaded
likiskwargsmeta-0.1.0.tar.gz 3.7 kB Details

Built distribution (wheel)

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

Total release size:8.0 kB

Release files / likiskwargsmeta-0.1.0.tar.gz

Download URL likiskwargsmeta-0.1.0.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
eeba9b9f874fecea8e1421a0fcbad4c30a47b17a7ac9dc0c4624b582be0ca33f
BLAKE2b-256 checksum
How to use checksums
d79d1b9ce7a1f86f285d1dc107eb1247ccc03d9deaa1e3922489c595a3d72995
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.9

Release files / likiskwargsmeta-0.1.0-py3-none-any.whl

Download URL likiskwargsmeta-0.1.0-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8a44d0526aec37944e930f0e5a6c0f518e3822fff1fc6c685b391af05c0252b
BLAKE2b-256 checksum
How to use checksums
13daba0185262aaa9e6fb37e816c4f3a7236e00d265ff932f5324b9d5bfabc38
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.1.0 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