On Thursday 18 August 2016 03:29, Michael Selik wrote: >> You might find this https://glyph.twistedmatrix.com/2016/08/attrs.html an >> interesting read. >> > > I disagree with a few points from that blog post. > > 1. I don't mind typing so much. I like to be explicit. The attrs library > uses some overly-concise abbreviations. For example, what's the meaning of > ``@attrs.s`` or ``attrs.ib``?
They're puns. Literally. `attr.s` for "attrs", and `attr.ib` for "attrib(ute)". There are longer, non-punny synonyms for these, but I don't remember what they are. > 2. When inheriting from a namedtuple, I use the same class name for the > base and the child, so my reprs look good. Still, I think it is unfortunate that namedtuple does the wrong thing. Having to use the same name for the parent and child class could, potentially, make debugging more annoying. > 3. I don't bother to fieldnames.split() when passing fieldnames as a > space-separated string, because the split is unnecessary. Because namedtuple does the split for you. > 4. I *like* that namedtuple is backwards-compatible with tuples, so that > refactoring from tuples to namedtuples is easy. Correct. An "attrs" object is not a tuple. > 5. Inheritance is useful. Sure, there are times it fails, but that's true > for any technique. -- Steve -- https://mail.python.org/mailman/listinfo/python-list