Automatic creation of self properties from parameters.
Project description
auto_self_params
A python package to automatically assign parameters to self. This enables replacing code such as:
class A:
""" Typical Code. """
def __init__(self, param1, param2, kwparam1=0, kwparam2=0):
""" Create Example Class."""
self.param1 = param1
self.param2 = param2
self.kwparam1 = kwparam1
self.kwparam2 = kwparam2
# etc.
With code more like:
from auto_self_params import auto_self_params
class A:
""" Revised Code. """
def __init__(self, param1, param2, kwparam1=0, kwparam2=0):
""" Create Example Class."""
auto_self_params(locals()) # Assign all parameters to self
# etc.
Only use this package if you need the paramters passed to __init__
to
produce matching names in self when called.
You can, however, create a dictionary with locals and remove unwanted
paramters before passing it to auto_self_params
so as to exclude unwanted
parameters.
Note that this cannot yet be used with the:
def __init__(self, *args, **kwargs):
format.
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
auto_self_params-0.0.1.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for auto_self_params-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bc70bdbad77cda2368121339798fecedfa988bab8fb40d16e4701c1070b6ba6 |
|
MD5 | 47b913601a7c103ff55e219475151533 |
|
BLAKE2b-256 | da93c631cd906174f52901555678c10136c9002a99f495953f401f6b73ff88e9 |