Distribution vs package naming #1200
-
Hi @cjolowicz, Thank you for your great series of articles and this template, this is very useful and I am learning a lot! I have a question about naming for distributions and packages. I saw the following statement in the Chapter 1:
Surprisingly for me I can't explain to myself why hyphens are used for distributions, not underscores, and didn't find any best practices on it. Could you please tell what is the reason for you to choose hyphens for distribution names? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
Thanks for asking an interesting question, and for writing the article! I particularly liked that you gathered data about existing naming practices from PyPI. Personally, I prefer package names with hyphens because I find them easier to read. Hyphens have been a part of standard typography since Gutenberg.1 By contrast, we've had the underscore character only since the advent of typewriters. According to this thesis, it was a fixture of the keyboard by 1881, and used for underlining by backing up the carriage and typing over the previous letter. It became a part of ASCII in 1963, and the C programming language made it a legal character in identifiers in the 1970s. I think you'd be hard-pressed to find a text with underscores that's not aimed at technical people. What's more, the original purpose of underscores was to provide underlining for devices that support inserting multiple characters in the same position. I still find it somewhat weird to read identifiers that underline the gaps between words, but not the words themselves. This is obviously a personal choice, and there are well-known projects using underscores in their names. To name one prominent example, the import sorter previously used by this template was reorder_python_imports. Using underscores for both distribution and import names has the advantage of consistency, as hyphens are not legal characters in Python identifiers, while underscores are. Worth noting that PEP 503 treats the three non-alphanumeric characters ( Footnotes
|
Beta Was this translation helpful? Give feedback.
-
Wow thank you for such comprehensive answer! Would you mind letting me include this information to the update of my blog post (referring to your answer)? I definitely need to restructure and enhance the description in the post:
Thank you. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi Claudio, I substantially restructured the article and also added the information that you provided. Thanks a lot for your help! |
Beta Was this translation helpful? Give feedback.
Thanks for asking an interesting question, and for writing the article! I particularly liked that you gathered data about existing naming practices from PyPI.
Personally, I prefer package names with hyphens because I find them easier to read. Hyphens have been a part of standard typography since Gutenberg.1
By contrast, we've had the underscore character only since the advent of typewriters. According to this thesis, it was a fixture of the keyboard by 1881, and used for underlining by backing up the carriage and typing over the previous letter. It became a part of ASCII in 1963, and the C programming language made it a legal character in identifiers in the 1970s. I think you'd be hard-pr…