- Daniel Arbuckle's Mastering Python
- Daniel Arbuckle
- 186字
- 2021-07-02 21:09:38
Adding modules to the package
Now, let's take look at how to add actual code to the package and look out for a couple of pitfalls to avoid.
Python modules have the same name as objects that they have as filenames, except without the .py suffix. This means that the filenames need to be valid Python variable names and also that they should use letters and symbols that are reliably available across different operating systems. The following screenshot showns an example for this:

So, module names should not start with a number because Python variables are not allowed to start with numbers. Also, it should not use capital letters because some common operating system don't differentiate between filenames containing capital letters and filenames that are all lowercase. As long as we stay within Python variable name guidelines and remember to use a .py suffix, we can name our modules anything we please.
So, we just pick a filename and start writing Python code into a file with that name in the package folder. That simple scenario is also the common case, but there's another possibility.
- C++案例趣學
- The DevOps 2.3 Toolkit
- Software Testing using Visual Studio 2012
- Android 應用案例開發(fā)大全(第3版)
- Android開發(fā):從0到1 (清華開發(fā)者書庫)
- Mastering Android Game Development
- Tableau 10 Bootcamp
- NoSQL數(shù)據(jù)庫原理
- HTML 5與CSS 3權威指南(第3版·上冊)
- Frank Kane's Taming Big Data with Apache Spark and Python
- 愛上C語言:C KISS
- Practical Predictive Analytics
- JavaScript悟道
- Web開發(fā)的平民英雄:PHP+MySQL
- PostgreSQL 12 High Availability Cookbook