attributes


Keywords
attribute
License
MIT
Install
pip install attributes==0.1.1

Documentation

attributes

GitHub Build Status PyPI

a python version attribute like attribute of csharp.

Usage

from attributes import Attribute

class Data(Attribute): # make your own attribute
    def __init__(self, *args, **kwargs):
        self.args = args
        self.kwargs = kwargs

@Data(1, 2) # use your attribute
class SomeClass:
    pass

data, = Attribute.get_attrs(SomeClass) # than load on runtime and use it.

Parameter Attribute

@param_attr('a', Data(1, 2), Data(3, 4))
def func(a):
    pass

data, = Attribute.get_attrs(param_of(func, 'a'))
# or
data, = Data.get_from_param(func, 'a')