corelp.selfkwargs module

corelp.selfkwargs(self, kwargs)[source]

This function takes a dictionnary (kwargs) and sets all its values to an object (self).

Parameters:
  • self (object) – Object instance where to set attributes.

  • kwargs (object) – Dictionnary defining which attributes to set and its values.

Examples

>>> from corelp import selfkwargs
...
>>> # Typicall use is in __init__ function :
>>> class MyClass :
...     def __init__(self, **kwargs) :
...         selkwargs(self, kwargs) # Sets all the keyword arguments to self
...
>>> instance = MyClass(a=1, b=2)
>>> print(instance.a)
1
>>> print(instance.b)
2