015第九章 CLASSES_續3_The Python Standard Library
💛20230115晨讀感言:
💔這句話解釋了為什麼會使用到 import :Sometimes you’ll want to spread out your classes over several modules ==to keep any one file from growing too large and avoid storing unrelated classes in the same module==.
💔得知 [The Python standard library](https://docs.python.org/3/library/index.html) ,既然我已學了 import 的運用,那麼,上面這個 library 裡面的 modules 等 資訊 絕對能夠在我寫 程式時 提供大量的支持。
💔在使用 [The Python standard library] 裡的 modules 時,你會發現 improt 的「對象」,不見得是 ==開頭大寫 的 Class==,有可能是 ==開頭小寫的 function==。而這也讓我聯想到之前學 Functions 裡也有使用 modules ,並運用 import 方式 載入到 你的程式中 運用。
💔==只要使用 improt 的「對象」,就可以 在 對象 的後面 加上() 來 呼叫 function 或 完成建置 Class 的 instance ==。結論: 對象 的開頭是大寫的 Class 時,才能稱之 完成建置 該 對象 的 inctance ,即 「 對象() 」,否則,就只是 單純 地 呼叫 function 來使用。
💛晨讀摘要:
💚178 If you need to import many classes from a module, you’re better off importing the entire module and using the _module_name_._class_name_ syntax.
💚180 The Python Standard Library: [The Python standard library] is a set of modules included with every Python installation. Now that you have a basic understanding of how functions and classes work, you can start to use modules like these that other program- mers have written. You can use any function or class in the standard library by including a simple import statement at the top of your file. Let’s look at one module, random, which can be useful in modeling many real-world situations.
💚181 Styling Classes: Class names should be written in _CamelCaps_. To do this, capitalize the first letter of each word in the name, and **don’t use underscores.** Instance and module names should be written in lowercase with underscores between words.
💚Within a class you can use one blank line between methods, and within a module you can use two blank lines to separate classes.
💚If you need to import a module from the standard library and a module that you wrote, place the import statement for the standard library module **first**. Then add a blank line and the import statement for the module you wrote.
from :《python crash course》