14 ms·
I absolutely hate the attrs “joke” names attr.ib and attr.s. That’s it. I simply can’t stand them, they drive me crazy. When I first saw them I wondered what t
by da39a3ee 5y ago
I absolutely hate the attrs “joke” names attr.ib and attr.s.
That’s it. I simply can’t stand them, they drive me crazy. When I first saw them I wondered what the fuck “ib” meant. And the thing is, I’d expect every decent python programmer to have the same reaction: . is syntax; it simply can’t be part of a name. The library is called “attrs”, so why is it imported as “attr”? I simply don’t know what the author thought he was doing.
I just don’t see how it is appropriate for a serious library to contain a joke that’s going to trip up literally every programmer with any taste. Maybe this is my problem, maybe one day I’ll relax and wonder why I was making such a big deal about it. But for the last several years it has made me think that the author completely lacks the judgement required to be a library author.
To add to my criticisms, imagine what the python ecosystem would look like if everyone thought they could have names that spanned attribute lookup syntax!
- kubami 5y agoThe `attrs` authors address it in the documentation: https://www.attrs.org/en/stable/overview.html#on-the-attr-s-and-attr-ib-names https://www.attrs.org/en/stable/overview.html#on-the-attr-s-... At first, some people have a negative gut reaction to that; resembling the reactions to Python’s significant whitespace. And as with that, once one gets used to it, the readability and explicitness of that API prevails and delights. For those who can’t swallow that API at all, attrs comes with serious business aliases: attr.attrs and attr.attrib.
- da39a3ee 5y agoYes, I know. That doesn’t redeem it. I want never to have to read those names in python code I'm working with; the documentation entry doesn't achieve that. And anyway, the library is called “attrs”, so why is it imported as “attr”?
- KptMarchewa 5y ago>And anyway, the library is called “attrs”, so why is it imported as “attr”? Python packaging is terrible, and giving package authors footguns like this. It's possible that it would be imported as "da39a3ee".
- da39a3ee 5y ago"attr" is the choice of the library designers. The question is why did they choose that name when users will expect it to be imported as "attrs"? Clearly if they had chosen "da39a3ee" we wouldn't need to discuss whether they had good judgement.
- nerdponx 5y agoThe package can contain entirely arbitrary module names. Any similarity in naming is by convention only. Don't quote me on this, but I don't see why two different packages can't contain the same module name and overwrite each other.
- HelloNurse 5y agoIf it is a problem, import attr as attrs which is probably what I would do for consistency.
- da39a3ee 5y agoI want never to see the names attr.ib and attr.s in code that I am working on. So I don't understand how your suggestion solves the problem: it might not be me writing the code.
- stavros 5y agoI never want to see Javascript code either, but being annoyed at Brendan Eich all the time is a bit futile.
- drewcoo 5y agoImagine we're in an elevator together and I said "I'm gonna fart now" then I passed gas. Would my saying so make it better? Admitting to doing something obnoxious does not make it less obnoxious. If anything, it makes it more so. It says the person knew what they were doing was a problem and they wanted to share the problem with everyone.
- WesolyKubeczek 5y agoWe need more cute aliases! @att.rs # because it refers to both AT&T and Rust @at.trs # musicians will love it @a.ttrs # because I never remember where the dot goes @ttrs # because @ looks like an a @lready @trs # @ is “at”! Get it? @t.rs # I like both Perl and Rust
- da39a3ee 5y agoHaha, thanks! I think I'm warming to the idea now.