Skip to content

Commit 58e04ed

Browse files
committed
update
1 parent 65070a8 commit 58e04ed

File tree

962 files changed

+41961
-31341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

962 files changed

+41961
-31341
lines changed

DOCS/_static/right.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**Folders**
2+
3+
[<Go Back>](../right.html)
4+
5+
6+
7+
<table><thead><tr class="header"><th><strong>File</strong></th><th><strong>File</strong></th><th><strong>File</strong></th><th><strong>File</strong></th></tr></thead><tbody><tr class="odd"><td><a href="basic.css">basic.css</a> </td><td><a href="pygments.css">pygments.css</a> </td><td><a href="jquery.js">jquery.js</a> </td><td><a href="underscore.js">underscore.js</a> </td></tr><tr class="even"><td><a href="classic.css">classic.css</a> </td><td><a href="copybutton.js">copybutton.js</a> </td><td><a href="language_data.js">language_data.js</a> </td><td><a href="file.png">file.png</a> </td></tr><tr class="odd"><td><a href="default.css">default.css</a> </td><td><a href="doctools.js">doctools.js</a> </td><td><a href="sidebar.js">sidebar.js</a> </td><td><a href="py.png">py.png</a> </td></tr><tr class="even"><td><a href="pydoctheme.css">pydoctheme.css</a> </td><td><a href="documentation_options.js">documenta...ons.js</a> </td><td><a href="switchers.js">switchers.js</a> </td><td></td></tr></tbody></table>
8+
9+
Folders: 1
10+
Files: 15
11+
Size of all files: 245799 KB

DOCS/right.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
**Folders**
2+
3+
[&lt;Go Back&gt;](../right.html)
4+
5+
 [tutorial](tutorial/right.html)
6+
7+
 [\_static](_static/right.html)
8+
9+
10+
11+
Folders: 3

DOCS/tutorial/appendix.md

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
### Navigation
2+
3+
- [index](https://docs.python.org/3/genindex.html "General Index")
4+
- [modules](https://docs.python.org/3/py-modindex.html "Python Module Index") |
5+
- [next](https://docs.python.org/3/using/index.html "Python Setup and Usage") |
6+
- [previous](floatingpoint.html "15. Floating Point Arithmetic: Issues and Limitations") |
7+
- ![](../_static/py.png)
8+
- [Python](https://www.python.org/) »
9+
- [3.9.5 Documentation](https://docs.python.org/3/index.html) »
10+
- [The Python Tutorial](index.html) »
11+
-
12+
13+
|
14+
15+
<span id="tut-appendix"></span>
16+
17+
<span class="section-number">16. </span>Appendix<a href="#appendix" class="headerlink" title="Permalink to this headline">¶</a>
18+
===============================================================================================================================
19+
20+
<span id="tut-interac"></span>
21+
22+
<span class="section-number">16.1. </span>Interactive Mode<a href="#interactive-mode" class="headerlink" title="Permalink to this headline">¶</a>
23+
-------------------------------------------------------------------------------------------------------------------------------------------------
24+
25+
<span id="tut-error"></span>
26+
27+
### <span class="section-number">16.1.1. </span>Error Handling<a href="#error-handling" class="headerlink" title="Permalink to this headline">¶</a>
28+
29+
When an error occurs, the interpreter prints an error message and a stack trace. In interactive mode, it then returns to the primary prompt; when input came from a file, it exits with a nonzero exit status after printing the stack trace. (Exceptions handled by an <a href="https://docs.python.org/3/reference/compound_stmts.html#except" class="reference internal"><code class="xref std std-keyword docutils literal notranslate">except</code></a> clause in a <a href="https://docs.python.org/3/reference/compound_stmts.html#try" class="reference internal"><code class="xref std std-keyword docutils literal notranslate">try</code></a> statement are not errors in this context.) Some errors are unconditionally fatal and cause an exit with a nonzero exit; this applies to internal inconsistencies and some cases of running out of memory. All error messages are written to the standard error stream; normal output from executed commands is written to standard output.
30+
31+
Typing the interrupt character (usually Control-C or Delete) to the primary or secondary prompt cancels the input and returns to the primary prompt. <a href="#id2" id="id1" class="footnote-reference brackets">1</a> Typing an interrupt while a command is executing raises the <a href="https://docs.python.org/3/library/exceptions.html#KeyboardInterrupt" class="reference internal" title="KeyboardInterrupt"><code class="sourceCode python"><span class="pp">KeyboardInterrupt</span></code></a> exception, which may be handled by a <a href="https://docs.python.org/3/reference/compound_stmts.html#try" class="reference internal"><code class="xref std std-keyword docutils literal notranslate">try</code></a> statement.
32+
33+
<span id="tut-scripts"></span>
34+
35+
### <span class="section-number">16.1.2. </span>Executable Python Scripts<a href="#executable-python-scripts" class="headerlink" title="Permalink to this headline">¶</a>
36+
37+
On BSD’ish Unix systems, Python scripts can be made directly executable, like shell scripts, by putting the line
38+
39+
#!/usr/bin/env python3.5
40+
41+
(assuming that the interpreter is on the user’s <span id="index-0" class="target"></span>`PATH`) at the beginning of the script and giving the file an executable mode. The `#!` must be the first two characters of the file. On some platforms, this first line must end with a Unix-style line ending (`'\n'`), not a Windows (`'\r\n'`) line ending. Note that the hash, or pound, character, `'#'`, is used to start a comment in Python.
42+
43+
The script can be given an executable mode, or permission, using the **chmod** command.
44+
45+
$ chmod +x myscript.py
46+
47+
On Windows systems, there is no notion of an “executable mode”. The Python installer automatically associates `.py` files with `python.exe` so that a double-click on a Python file will run it as a script. The extension can also be `.pyw`, in that case, the console window that normally appears is suppressed.
48+
49+
<span id="tut-startup"></span>
50+
51+
### <span class="section-number">16.1.3. </span>The Interactive Startup File<a href="#the-interactive-startup-file" class="headerlink" title="Permalink to this headline">¶</a>
52+
53+
When you use Python interactively, it is frequently handy to have some standard commands executed every time the interpreter is started. You can do this by setting an environment variable named <span id="index-1" class="target"></span><a href="https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSTARTUP" class="reference internal"><code class="xref std std-envvar docutils literal notranslate">PYTHONSTARTUP</code></a> to the name of a file containing your start-up commands. This is similar to the `.profile` feature of the Unix shells.
54+
55+
This file is only read in interactive sessions, not when Python reads commands from a script, and not when `/dev/tty` is given as the explicit source of commands (which otherwise behaves like an interactive session). It is executed in the same namespace where interactive commands are executed, so that objects that it defines or imports can be used without qualification in the interactive session. You can also change the prompts `sys.ps1` and `sys.ps2` in this file.
56+
57+
If you want to read an additional start-up file from the current directory, you can program this in the global start-up file using code like `if os.path.isfile('.pythonrc.py'): exec(open('.pythonrc.py').read())`. If you want to use the startup file in a script, you must do this explicitly in the script:
58+
59+
import os
60+
filename = os.environ.get('PYTHONSTARTUP')
61+
if filename and os.path.isfile(filename):
62+
with open(filename) as fobj:
63+
startup_file = fobj.read()
64+
exec(startup_file)
65+
66+
<span id="tut-customize"></span>
67+
68+
### <span class="section-number">16.1.4. </span>The Customization Modules<a href="#the-customization-modules" class="headerlink" title="Permalink to this headline">¶</a>
69+
70+
Python provides two hooks to let you customize it: `sitecustomize` and `usercustomize`. To see how it works, you need first to find the location of your user site-packages directory. Start Python and run this code:
71+
72+
>>> import site
73+
>>> site.getusersitepackages()
74+
'/home/user/.local/lib/python3.5/site-packages'
75+
76+
Now you can create a file named `usercustomize.py` in that directory and put anything you want in it. It will affect every invocation of Python, unless it is started with the <a href="https://docs.python.org/3/using/cmdline.html#cmdoption-s" class="reference internal"><code class="xref std std-option docutils literal notranslate">-s</code></a> option to disable the automatic import.
77+
78+
`sitecustomize` works in the same way, but is typically created by an administrator of the computer in the global site-packages directory, and is imported before `usercustomize`. See the documentation of the <a href="https://docs.python.org/3/library/site.html#module-site" class="reference internal" title="site: Module responsible for site-specific configuration."><code class="sourceCode python">site</code></a> module for more details.
79+
80+
Footnotes
81+
82+
<span class="brackets"><a href="#id1" class="fn-backref">1</a></span>
83+
A problem with the GNU Readline package may prevent this.
84+
85+
### [Table of Contents](https://docs.python.org/3/contents.html)
86+
87+
- <a href="#" class="reference internal">16. Appendix</a>
88+
- <a href="#interactive-mode" class="reference internal">16.1. Interactive Mode</a>
89+
- <a href="#error-handling" class="reference internal">16.1.1. Error Handling</a>
90+
- <a href="#executable-python-scripts" class="reference internal">16.1.2. Executable Python Scripts</a>
91+
- <a href="#the-interactive-startup-file" class="reference internal">16.1.3. The Interactive Startup File</a>
92+
- <a href="#the-customization-modules" class="reference internal">16.1.4. The Customization Modules</a>
93+
94+
#### Previous topic
95+
96+
[<span class="section-number">15. </span>Floating Point Arithmetic: Issues and Limitations](floatingpoint.html "previous chapter")
97+
98+
#### Next topic
99+
100+
[Python Setup and Usage](https://docs.python.org/3/using/index.html "next chapter")
101+
102+
### This Page
103+
104+
- [Report a Bug](https://docs.python.org/3/bugs.html)
105+
- [Show Source](https://github.com/python/cpython/blob/3.9/Doc/tutorial/appendix.rst)
106+
107+
### Navigation
108+
109+
- [index](https://docs.python.org/3/genindex.html "General Index")
110+
- [modules](https://docs.python.org/3/py-modindex.html "Python Module Index") |
111+
- [next](https://docs.python.org/3/using/index.html "Python Setup and Usage") |
112+
- [previous](floatingpoint.html "15. Floating Point Arithmetic: Issues and Limitations") |
113+
- ![](../_static/py.png)
114+
- [Python](https://www.python.org/) »
115+
- [3.9.5 Documentation](https://docs.python.org/3/index.html) »
116+
- [The Python Tutorial](index.html) »
117+
-
118+
119+
|
120+
121+
© [Copyright](https://docs.python.org/3/copyright.html) 2001-2021, Python Software Foundation.
122+
The Python Software Foundation is a non-profit corporation. [Please donate.](https://www.python.org/psf/donations/)
123+
124+
Last updated on May 30, 2021. [Found a bug](https://docs.python.org/3/bugs.html)?
125+
Created using [Sphinx](https://www.sphinx-doc.org/) 2.4.4.

DOCS/tutorial/appetite.md

+83
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
### Navigation
2+
3+
- [index](https://docs.python.org/3/genindex.html "General Index")
4+
- [modules](https://docs.python.org/3/py-modindex.html "Python Module Index") |
5+
- [next](interpreter.html "2. Using the Python Interpreter") |
6+
- [previous](index.html "The Python Tutorial") |
7+
- ![](../_static/py.png)
8+
- [Python](https://www.python.org/) »
9+
- [3.9.5 Documentation](https://docs.python.org/3/index.html) »
10+
- [The Python Tutorial](index.html) »
11+
-
12+
13+
|
14+
15+
<span id="tut-intro"></span>
16+
17+
<span class="section-number">1. </span>Whetting Your Appetite<a href="#whetting-your-appetite" class="headerlink" title="Permalink to this headline">¶</a>
18+
==========================================================================================================================================================
19+
20+
If you do much work on computers, eventually you find that there’s some task you’d like to automate. For example, you may wish to perform a search-and-replace over a large number of text files, or rename and rearrange a bunch of photo files in a complicated way. Perhaps you’d like to write a small custom database, or a specialized GUI application, or a simple game.
21+
22+
If you’re a professional software developer, you may have to work with several C/C++/Java libraries but find the usual write/compile/test/re-compile cycle is too slow. Perhaps you’re writing a test suite for such a library and find writing the testing code a tedious task. Or maybe you’ve written a program that could use an extension language, and you don’t want to design and implement a whole new language for your application.
23+
24+
Python is just the language for you.
25+
26+
You could write a Unix shell script or Windows batch files for some of these tasks, but shell scripts are best at moving around files and changing text data, not well-suited for GUI applications or games. You could write a C/C++/Java program, but it can take a lot of development time to get even a first-draft program. Python is simpler to use, available on Windows, Mac OS X, and Unix operating systems, and will help you get the job done more quickly.
27+
28+
Python is simple to use, but it is a real programming language, offering much more structure and support for large programs than shell scripts or batch files can offer. On the other hand, Python also offers much more error checking than C, and, being a *very-high-level language*, it has high-level data types built in, such as flexible arrays and dictionaries. Because of its more general data types Python is applicable to a much larger problem domain than Awk or even Perl, yet many things are at least as easy in Python as in those languages.
29+
30+
Python allows you to split your program into modules that can be reused in other Python programs. It comes with a large collection of standard modules that you can use as the basis of your programs — or as examples to start learning to program in Python. Some of these modules provide things like file I/O, system calls, sockets, and even interfaces to graphical user interface toolkits like Tk.
31+
32+
Python is an interpreted language, which can save you considerable time during program development because no compilation and linking is necessary. The interpreter can be used interactively, which makes it easy to experiment with features of the language, to write throw-away programs, or to test functions during bottom-up program development. It is also a handy desk calculator.
33+
34+
Python enables programs to be written compactly and readably. Programs written in Python are typically much shorter than equivalent C, C++, or Java programs, for several reasons:
35+
36+
- the high-level data types allow you to express complex operations in a single statement;
37+
38+
- statement grouping is done by indentation instead of beginning and ending brackets;
39+
40+
- no variable or argument declarations are necessary.
41+
42+
Python is *extensible*: if you know how to program in C it is easy to add a new built-in function or module to the interpreter, either to perform critical operations at maximum speed, or to link Python programs to libraries that may only be available in binary form (such as a vendor-specific graphics library). Once you are really hooked, you can link the Python interpreter into an application written in C and use it as an extension or command language for that application.
43+
44+
By the way, the language is named after the BBC show “Monty Python’s Flying Circus” and has nothing to do with reptiles. Making references to Monty Python skits in documentation is not only allowed, it is encouraged!
45+
46+
Now that you are all excited about Python, you’ll want to examine it in some more detail. Since the best way to learn a language is to use it, the tutorial invites you to play with the Python interpreter as you read.
47+
48+
In the next chapter, the mechanics of using the interpreter are explained. This is rather mundane information, but essential for trying out the examples shown later.
49+
50+
The rest of the tutorial introduces various features of the Python language and system through examples, beginning with simple expressions, statements and data types, through functions and modules, and finally touching upon advanced concepts like exceptions and user-defined classes.
51+
52+
#### Previous topic
53+
54+
[The Python Tutorial](index.html "previous chapter")
55+
56+
#### Next topic
57+
58+
[<span class="section-number">2. </span>Using the Python Interpreter](interpreter.html "next chapter")
59+
60+
### This Page
61+
62+
- [Report a Bug](https://docs.python.org/3/bugs.html)
63+
- [Show Source](https://github.com/python/cpython/blob/3.9/Doc/tutorial/appetite.rst)
64+
65+
### Navigation
66+
67+
- [index](https://docs.python.org/3/genindex.html "General Index")
68+
- [modules](https://docs.python.org/3/py-modindex.html "Python Module Index") |
69+
- [next](interpreter.html "2. Using the Python Interpreter") |
70+
- [previous](index.html "The Python Tutorial") |
71+
- ![](../_static/py.png)
72+
- [Python](https://www.python.org/) »
73+
- [3.9.5 Documentation](https://docs.python.org/3/index.html) »
74+
- [The Python Tutorial](index.html) »
75+
-
76+
77+
|
78+
79+
© [Copyright](https://docs.python.org/3/copyright.html) 2001-2021, Python Software Foundation.
80+
The Python Software Foundation is a non-profit corporation. [Please donate.](https://www.python.org/psf/donations/)
81+
82+
Last updated on May 30, 2021. [Found a bug](https://docs.python.org/3/bugs.html)?
83+
Created using [Sphinx](https://www.sphinx-doc.org/) 2.4.4.

0 commit comments

Comments
 (0)