3 ms·
Also, read the post and looked over the docs, and don't see any explanation of what `.s` and `.ib` is supposed to mean (though I can figure out from context).
by mixmastamyk 10y ago
Also, read the post and looked over the docs, and don't see any explanation of what `.s` and `.ib` is supposed to mean (though I can figure out from context). Does anyone know what the letters stand for? Struct and instance b…???
- hynek 10y agohttp://attrs.readthedocs.io/en/latest/overview.html#on-the-attr-s-and-attr-ib-names http://attrs.readthedocs.io/en/latest/overview.html#on-the-a...
- jfb 10y agoattr.s = "attrs" = plural of "attr" attr.ib = "attirb" = alternate spelling of "attr" It's too cute by half.
- ctoth 10y agoIt's awesome that Glyph wrote this article, but so many people are getting stuck on the default names here (me too, I don't like them so very much) that it's really detracting from the commentariet. From the Attrs documentation: (If you don’t like the playful attr.s and attr.ib, you can also use their no-nonsense aliases attr.attributes and attr.attr).
- 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...