libb.include
- include(source, names=())[source]
Include dictionary items as class attributes during class declaration.
Injects dictionary key-value pairs into the calling class namespace, optionally filtering by specific names.
- Parameters:
- Return type:
Include All Attributes:
>>> d = dict(x=10, y='foo') >>> class Foo: ... include(d) >>> Foo.x 10 >>> Foo.y 'foo'
Include Specific Attributes:
>>> class Boo: ... include(d, ('y',)) >>> hasattr(Boo, 'x') False >>> hasattr(Boo, 'y') True