译者按:使用 ev3dev Linux 系统并用 Python 编程的人数比例很低,好像这一课这样写 Python 编程的就更少了,你会发现程序的重用率会大大的提高!
EV3: Lesson 4 - Python Modules
EV3:第 4 课 - Python 模块
4.1 Separate Functions, Main Program and Global Variables
4.1 分开的函数,主程序,和全局变量
In our last lesson, we learned how to use functions to perform repeated jobs. However, if the main program contains too many functions, the program size will become too large to be maintained. So, we'll need some technique to separate those functions with the main program.
在我们的上一课,我们学习了如何使用函数去执行一些重复的工作。但是,如果主程序里有太多的函数,程序会变得太大而难以维护。所以,我们需要一些技巧去分开主程序和函数。
Those python program files that stored functions are called "Python Modules".
我们叫那些储存函数的档案为【Python 模块】。
In order to share variables between different python programs and modules, we'll also need to put the global variables to a seperate python module. (Note: global var