Skip to main content

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.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.

If you would like to use the: def __init__(self, *args, **kwargs): format then you may wish to use a pattern such as:

from auto_self_params import auto_self_params

class A:
    """ Revised Code. """
    def __init__(self,  *args, **kwargs):
        """ Create Example Class."""
        param_dict = {'self': self, 'args': args, **kwargs}
        auto_self_params.auto_self_params(param_dict)  # Assign parameters to self
        # etc.

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

auto_self_params-0.0.2.tar.gz (2.6 kB view details)

Uploaded Source

Built Distribution

auto_self_params-0.0.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file auto_self_params-0.0.2.tar.gz.

File metadata

  • Download URL: auto_self_params-0.0.2.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for auto_self_params-0.0.2.tar.gz
Algorithm Hash digest
SHA256 c6a52f68dddea4261b019f7f7b3599381baa8d1cb1a82f164b3ffcdf0be0a306
MD5 d872247b4beb5e30520994a073c970c4
BLAKE2b-256 e0deb73f3cbe7936fd4eb9c041c84c9e1add72e132d5abb4bfb9dd8b8c2ba7bd

See more details on using hashes here.

File details

Details for the file auto_self_params-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: auto_self_params-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for auto_self_params-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 28f77a1cb5b505123dcd45bb4a429921646a27b1358e581bbe9bdbe01e0fbfb2
MD5 1be1c415e99eea85b40f178cc3453e71
BLAKE2b-256 d557dfc61eb1167b2e1d4f513715652263e6ebf0650b29fa09c0af34d9e9775e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page