4 ms·
The `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/sta
by kubami 5y ago
The `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.