为什么python模块名称有一些大写字母但总是以小写形式导入? [英] Why do python module names have some uppercase letters but are always imported in lowercase?

查看:56
本文介绍了为什么python模块名称有一些大写字母但总是以小写形式导入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我看到对 SciPy 和 NumPy 等模块的引用时,每个部分的第一个字母都会大写.但是,它们必须全部使用小写字母导入.为什么会有这种差异?

Whenever I see references to modules like SciPy and NumPy the first letter of each part is capitalized. However they must be imported with all lowercase letters. Why is there this difference?

推荐答案

区别主要在于品牌.根据样式指南:https://www.python.org/dev/peps/pep-0008/#package-and-module-names 模块名称应简短且全部小写.原因之一是当您导入模块时,如果您必须记住名称中的所有大写字母会很不方便.像 NumPy 和 SciPy 这样的大包遵循这个约定,但是当它们指代自己(或当其他人指代它们时)时,它们喜欢包含风格大写.这主要是一种风格/品牌选择.

The difference is basically in branding. As per the style guide: https://www.python.org/dev/peps/pep-0008/#package-and-module-names module names should be short and all lower cased. One reason for that is that when you are importing a module, it would be inconvenient if you had to remember all the capitalizations in the name. Big packages like NumPy and SciPy follow this convention, but when they are referring to themselves (or when others are referring to them) they like to include the stylistic capitalizations. It's mostly a style/branding choice.

这篇关于为什么python模块名称有一些大写字母但总是以小写形式导入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆