pyAttributes Module


This Python module offers the base implementation of .NET-like attributes realized with Python decorators. This module comes also with a mixin-class to ease using classes having annotated methods.

The decorators in pyAttributes are implemented as class-based decorators.

The annotated data is stored in an additional __dict__ entry for each annotated method. By default the entry is called __pyattr__.


A type variable for functions. Here it’s used for methods.

alias of TypeVar(‘Func’)


A type variable for Attribute.

alias of TypeVar(‘TAttr’)


A type hint for a filter parameter that accepts either a single Attribute or an iterable of those.

alias of Optional[Union[TAttr, Iterable[TAttr]]]


class pyAttributes.Attribute[source]

Bases: object

Base-class for all pyAttributes.


Make all classes derived from Attribute callable, so they can be used as a decorator.

Return type


classmethod GetAttributes(method, includeSubClasses=True)[source]

Returns attached attributes for a given method.

Return type



class pyAttributes.AttributeHelperMixin[source]

Bases: object

A mixin class to ease finding methods with attached pyAttributes.

static HasAttribute(method, filter=<class 'pyAttributes.Attribute'>)[source]

Returns true, if the given method has pyAttributes attached.

Return type


static GetAttributes(method, filter=<class 'pyAttributes.Attribute'>)[source]

Returns a list of pyAttributes attached to the given method.

Return type