python learning manual notes --03 how to run the program

00. Why use the interactive prompt: interactive prompt response to user input and run the code in response to the results, but he does it to save the code to a file, even if it means you can not write a lot of Aunt interactive painting, but the interactive prompt still a good place to experience the language and test preparation of the program file.

The first principle 01. In fact, this is the need to keep in mind: When you doubt any time, up the interactive command line operation for some Python code implementation code and see what happens.

02. direct feedback received by the interactive prompt, usually when a piece of code in the end to find out what the fastest way to do it.

03. In order to permanently save the program, you need to write the code in the file, such files are usually called den Ae. Module is a Python statement contains a simple text file. Upon completion, the python interpreter can make multiple runs of such statements in the document, and you can go run a variety of ways; through the system command line] by clicking on the icon, the user interface by selecting IDLE lamp mode.

04. For all of the top-level file, the script should be called directly, however, to be imported into the client code must file with .py suffix. Some text editor to detect Python files .py suffix. Without this extension, it may not be available, such as syntax coloring and automatic indentation.

05. Each of the end with the extension .py Python source code is a tapered block. Other files can read the contents of the module by introducing a module. Import In essence, is to load another file, and be able to read the contents of that file. The contents of a module can be used by such woke up to the outside world.

06.Python program often communicate by multiple module files, connect the instrument through import statements. A separate variable packet younger each module file, i.e., a namespace. I do see a module can not see the variable names defined in other documents, it is explicitly non-Organization import the file, so I do see modules minimize naming conflicts play a role in the code file. Because each file is obviously a self-contained space, even though they are spelled in the same circumstances, when the variable name is not a file in another file variables in the conflict.

07.import VS from: I should point out, from the statement in a sense defeated the purpose name space module separated, because from the variable copy from one file to another, which could lead to import it I see in variable of the same name is overwritten. This will lead to a fundamental instrument in the name of spatial overlap, overlap at least back on the copied variable.

08. The basic import file statements each process runs only once and return it to generate the file into a separate module namespace, so that its replication does not change the scope of your variables. The module name space separating the price paid, after modifications need to reload.

Guess you like

Origin www.cnblogs.com/aixiaoxiaoyu/p/11204885.html