3 ms·
> They are a concise and highly readable way to write attrs and attrib with an explicit namespace. > For those who can’t swallow that API at all, attrs comes w
by Myrmornis 10y ago
> They are a concise and highly readable way to write attrs and attrib with an explicit namespace.
> For those who can’t swallow that API at all, attrs comes with serious business aliases: attr.attrs and attr.attrib.
I'm definitely in the can't swallow camp. There's no precedent for using attribute namespaces to name things with half the name on one side and half the name on the other side, so who the hell does this project think it is to start doing it? :) Seriously though I'm pretty sure I hate it.
And I'm having trouble liking the "proper" names. So we use a class decorator "@attrs" to declare "this class is going to use class attributes to declare available instance attributes slots, a bit like django or schematics fields". Maybe it would have been better to call it "@attrs.model" since it is essentially a model definition in the terminology of other data modeling projects?
- gknoy 10y agoIf you use `import ... as ...`, you can rename them to nicer names (full gist at [0]): from attr import ( s as AttributedModel, ib as attribute, ) @AttributedModel class Bar(object): x = attribute() y = attribute() 0: https://gist.github.com/gknoy/6e884fce3edda08a1566823fec37ba70 https://gist.github.com/gknoy/6e884fce3edda08a1566823fec37ba...