AByteofPythonRussian-2 01
AByteofPythonRussian-2 01
2.01
22 August 2013
.
.
.
.
.
.
.
1
1
1
5
5
5
5
6
2.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
7
7
3.1 . . . . .
3.2 . . . . . .
3.3 . . . . . .
3.4 -
3.5 . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
15
15
15
16
16
17
19
4.1 Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
4.2 Python 2 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
23
5.1 GNU/Linux BSD . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.2 Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.3 Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
i
5.4
6
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
6.1 . . . . . . . . . . . . . . . . . . . . . . . . . .
6.2
6.3 . . . . . . . . . . . . . . . . . . . . .
6.4 . . . . . . . . .
6.5 . . . . . . . . . . . . . . . . . . . .
6.6 . . . . . . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
27
27
27
28
29
33
33
7.1 . . . . . . . . . . . .
7.2 . . . . . .
7.3 . . . . . . . . . . . . . . . . .
7.4 . . . . . . . . . . . . . . . .
7.5 . . . . . . . . . . . . .
7.6 . . . . .
7.7 . . . . . . . . . . . .
7.8 . . . . . . . . . . . . . . .
7.9
7.10 . . . . . . . . . . . . . . .
7.11 . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
35
35
36
36
36
39
39
40
40
41
42
44
8.1 . . . . . . . . . . . . .
8.2 . . . . . . .
8.3
8.4 . . . . . . . . .
8.5 . . . . . . . . . . . . .
8.6 . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
45
45
48
49
50
50
50
.
.
.
.
.
.
51
51
53
55
56
58
58
.
.
.
.
.
59
60
61
61
62
63
9.1 if . . . .
9.2 while .
9.3 for . . . . . .
9.4 break .
9.5 continue
9.6 . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
10
10.1 . . . . . . . . . .
10.2 . . . . . . . .
10.3 global . .
10.4 nonlocal
10.5
ii
.
.
.
.
.
.
26
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
10.6
10.7
10.8
10.9
10.10
10.11
10.12
. . . . . .
.
return . . . . . . . .
. . . . .
. . . . . . . . . . . .
. . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
64
65
66
67
68
69
69
11
11.1 .pyc . . . . . . .
11.2 from import . . . .
11.3 __name__ . . . . .
11.4
11.5 dir . . . . . . . . . . . .
11.6 . . . . . . . . . . . . . . .
11.7 . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
71
73
73
74
75
76
77
78
12
12.1 . . . . . . . . . . . . . . . . . .
12.2
12.3 . . . . . . . . . . . . . . . . . .
12.4 . . . . . . . . . . . . . . . . . .
12.5 . . . . . . . . . .
12.6 . . . . . . . . . . . . . . . .
12.7 . . . . . . . . . . . . . . . . . .
12.8 . . . . . . . . . . . . . .
12.9 . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
79
79
79
81
83
85
87
88
89
90
13
13.1 . . . . . . . . . . . . . . . . . . . . . . . . . .
13.2 . . . . . . . . . . . . . . . . . . . . . . . .
13.3 . . . . . . . . . . . . . . . . . . . . .
13.4 . . . . . . . . . . . . . . . . . . . . .
13.5 . . . . . . . . . . . . . . . . . . .
13.6 . . . . . .
13.7
13.8 . . . . . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
91
. 91
. 92
. 94
. 96
. 97
. 99
. 99
. 100
.
.
.
.
.
.
101
102
102
103
103
104
108
14 -
14.1 self . . . . . . . . . . . . . . . . . . . . . . . . . .
14.2 . . . . . . . . . . . . . . . . . . . . . . .
14.3 . . . . . . . . . . . . . . . . .
14.4 __init__ . . . . . . . . . . . . . . . . . .
14.5 . . . . . . . . . .
14.6 . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
iii
14.7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
14.8 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
15 -
15.1
15.2 . . . . . . . . .
15.3 Pickle . . . . . . . . .
15.4 . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
113
113
114
116
117
16
16.1 . . . . . . . . . .
16.2 . . . . . . .
16.3
16.4 . . .
16.5 Try .. Finally . . . . . . . .
16.6 with . . . . . .
16.7 . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
119
119
119
120
121
122
123
124
17
17.1 sys . . . . . . . .
17.2 logging . . . . .
17.3
17.4 . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
125
125
126
128
128
18
18.1 . . . . . . . . . . . . . .
18.2 . . . . . . . . . . . .
18.3 . . . . . . . . . .
18.4 Lambda- . . . . . . . . . . . . . . . . .
18.5 . . . . . . . . . . . . .
18.6
18.7 exec eval . . . . . . . . . . . . . . . . . . .
18.8 assert . . . . . . . . . . . . . . . .
18.9 repr . . . . . . . . . . . . . . . . . .
18.10 . . . .
18.11 . . . . . . . . .
18.12 . . . . . . . . . . . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
129
129
130
130
131
131
132
132
133
133
134
134
135
19
19.1 . . . . . . .
19.2 . .
19.3 . . . .
19.4
19.5 . . . . . . . . .
19.6 . . . . . . . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
137
138
138
138
138
139
139
iv
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
19.7
19.8
19.9
19.10
19.11
19.12
19.13
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
( ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19.14 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20 : FLOSS
20.1 Free/Libre and Open Source Soware (FLOSS)
.
.
.
.
.
.
139
139
139
139
140
141
. 141
. 142
143
. . . . . . . . . . . . . . . . . . . 143
21 :
145
21.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
21.2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
22 :
147
23 :
151
vi
1.1 A Byte of Python -
:
A Byte of Python1 .
Swaroop Chitlur.
2
2.0 2.01
.
A Byte of Python ( ) - , A
Bite of Python (..)
2
e-mail:
v_2e@[Link]
Python , . .
!
Joshua Robin (joshrob-at-poczta-dot-onet-dot-pl)
#Python
Shan Rajasekaran
A Byte of Python , . ,
OReilly - Python. .
Samuel Young (sy-one-three-seven-at-gmail-dot-com)
! Python,
. ! ! !
Chris-Andr Sommerseth
1.
. ,
, .
Ma Gallivan (m-underscore-gallivan12-at-hotmail-dot-com)
, Python
A Byte of Python, Swaroop C H 110 . , , ,
Python
Drew Ames Scripting Scribus, [Link]
A Byte of Python , .
Patrick Harrington, StackOverow
NASA
! 3 4 .
Vrije,
Python
3
4
1.
1.3
Creative Commons AributionShare Alike 3.0 Unported.
, :
,
:
, .
hp://[Link]/notes/Python
, .
/, , BSD5 , .
1.4
.
1.5
,
, ( ).
1.6
PDF-
EPUB ( ).
,
.
5
1.3.
1.7
,
.
1.
,
.
, , .
, , , .
2.1
2.1.1
. Ashraf Ali Khalaf
.
[Link]. . .
2.1.2
:
Samuel Dias Neto ([Link]-at-gmail-dot-com)
Python 2.3.5.
Samuel aprendendopython.
Rodrigo Amaral (rodrigoamaral-at-gmail-dot-com)
.
Rodrigo .
2.1.3
Moises Gomez (moisesgomezgiron-at-gmail-dot-com) . , erstwhile wiki.
Moiss Gmez:
7
2.1.4
.
Juan Shen (orion-underscore-val-at-163-dot-com)
.
.
, . , CDMA.
Python . , Python
Numeric. Python , , , , . Swaroop,
.
A Byte of Python Python. Python . ,
Python. , A Byte of
Python .
Python
.
2.1.5
Fred Lin (gasolin-at-gmail-dot-com) .
hp://[Link]/p/zhpy/wiki/ByteOfZhpy .
8
2.
2.1.6
Gregory (coulix-at-ozforces-dot-com-dot-au) .
Grard Labadie (Palmipede) . .
2.1.7
Lutz Horn (lutz-dot-horn-at-gmx-dot-de), Bernd Hengelein (bernd-dot-hengelein-at-gmail-dotcom) Christoph Zwerske (cito-at-online-dot-de) .
hp://[Link] .
Lutz Horn :
32 , . - .
, , Java,
Python. Python. , -,
Java- Struts.
2.1.
2.1.8
Ubuntu ),
Python .
@savvasradevic.
10
2.
2.1.9
Daniel (daniel-dot-mirror-at-gmail-dot-com)
hp://[Link]/[Link]/ByteofPython .
W. Priyambodo . hp://[Link]/notes/Python_id:Daar_Isi .
2.1.10
Enrico Morelli (mr-dot-mlucci-at-gmail-dot-com) Massimo Lucci (morelli-at-cerm-dot-unidot-it) .
[Link]/Programmazione/byteofpython .
: hp://[Link]/notes/Python_it:Prefazione .
Massimo Lucci Enrico Morelli:
() . (Massimo) , Enrico
/ . Python
, Linux . - [Link] Gentoo/Linux,
[Link] ( )
. !
, , ,
Python (,
).
2.1.11
.
Shunro Dozono (dozono-at-gmail-dot-com) .
2.1.12
Ariunsanaa Tunjin (luballons2010-at-gmail-dot-com) .
22 2009 : Ariunsanaa .
2.1.13 (bokml)
Eirik Vgeskar Sandvika videregende skole , , (bokml). .
.
2.1.
11
2.1.14
Dominik Kozaczko (dkozaczko-at-gmail-dot-com) .
, : Uk Pythona.
: 2 2009. . , !
Dominik Kozaczko: .
2.1.15
Fidel Viegas (del-dot-viegas-at-gmail-dot-com)
.
2.1.16
Paul-Sebastian Manole (brokenthorn-at-gmail-dot-com)
.
Paul-Sebastian Manole:
Spiru
Haret University, . , -
Python. ,
, A Byte of Python.
( , ). Python,
Swaroop . , ,
.
hp://[Link]/notes/Python_ro .
12
2.
2.1.17
(v_2e-at-ukr-dot-net) .
hp://[Link]/AByteOfPython .
2.1.18
Averkiev Andrey (averkiyev-at-ukr-dot-net)
( ).
2.1.19
Albertio Ward (albertioward-at-gmail-dot-com) :
. , , . : , , ..
, . ,
. , .
.
? ,
.
, ,
. , .
, .
2.1.20
Alfonso de la Guarda Reyes (alfonsodg-at-ictechperu-dot-net), Gustavo Eeverria (gustavodot-echeverria-at-gmail-dot-com), David Crespo Arroyo (davidcrespoarroyo-at-hotmail-dotcom) Cristian Bermudez Serna (crisbermud-at-hotmail-dot-com)
. .
() .
Gustavo Eeverria :
. C# .NET ,
Python Ruby. Python ,
. Python ,
2.1.
13
2.1.21
Mikael Jacobsson (leochingkwake-at-gmail-dot-com) .
2.1.22
Trker SEZER (tsezer-at-burk-dot-net) Bugra Cakir (bugracakir-at-gmail-dot-com)
. ? Bitse de okusak.
: -at- @ , -dot- . -underscore- _
, .
.
14
2.
Python , , ,
. , ,
.
, ,
.
3.1
Python. , , . , .
, , , , Python . , Python .
, Python , . , ,
Python!
3.2
Python,
Diamond, .
Python Perl Qt.
. , , , Python .
, PyQt Perl-Qt.
Python.
Python. ! ,
OReilly, ,
15
3.3
2012 , , Pandoc , .
2008 (
2005 ) , Python 3.0.
,
. , , ,
.
3.4 -
hp://[Link]/notes/Python,
, ,
.
16
3.
3.5
: ,
, ;
, , .
C. A. R. Hoare
, .
C. W. Wendte
3.5.
17
18
3.
Python , . , , ,
.
Python :
Python .
,
, - . ,
,
.
.
, Python,
BBC 1 , ,
,
.
4.1 Python
4.1.1
Python . Python
, ! Python .
, .
1
19
4.1.2
, Python . Python
, .
4.1.3
Python FLOSS
(Free/Libr and Open Source Soware). , , ,
, .
, . , Python : ,
.
4.1.4
Python , , , ..
4.1.5
, Python (.. , ).
- , - .
Python GNU/Linux, Windows, FreeBSD, Macintosh, Solaris, OS/2,
Amiga,AROS, AS/400, BeOS, OS/390, z/OS, Palm OS, QNX, VMS, Psion, Acorn RISC OS, VxWorks,
PlayStation, Sharp Zaurus, Windows CE PocketPC!
, Kivy iOS
(iPhone, iPad) Android.
4.1.6
.
, , , C
C++, (.. C C++) , ( , .. )
. , / .
Python , , . . Python
20
4.
4.1.7 -
Python -, . - ,
- . ,
. Python ,
, , C++ Java.
4.1.8
,
,
C C++, Python.
4.1.9
Python C/C++, .
4.1.10
Python .
, , , , , , -, CGI, FTP, , XML, XML-RPC, HTML, WAV
, , GUI ( )
- . , , Python. Python .
, , Python
4.1. Python
21
4.2 Python 2 3
Python 2 Python 3,
. , .
2008 Python 3. , Python 3. , , ,
Python 2 Python 3 . ,
Python 3.
, Python 3, Python 2. ,
,
.
Python. ,
, Python 2 Python 3
.
Python 2 Python 3 Ubuntu wiki,
Python 3.
4.3
, , , Python:
1. . , ,
Open Source. , Python . Python.
2. Java ++.
, , Python. , , Python , , , .
.
3. Lisp, Google ( ). , Python
Google. ,
Google Jobs, Python .
22
4.
Python 2.x, ,
Python 3.0. .
: $ - . -
,
$.
, , Python .
:
$ python -V
bash: Python: command not found
, Python . , .
: Python 3.x, python3 -V.
Python:
Python . -.
23
5.2 Windows
hp://[Link]/download/ . , Windows.
: , ! , IDLE.
, Windows. , , GNU/Linux Python .
5.2.1 DOS
Python Windows, .. DOS, PATH.
Windows 2000, XP, 2003 , . PATH ,
;C:\Python33 , (, ,
Python ). ,
.
Windows C:\[Link] :
PATH=%PATH%;C:\Python33( ) . Windows NT [Link].
Windows Vista:
1.
2. ,
. , . .
. .
3. Path
.
24
5.
4. Ok, . .
5.3 Mac OS X
Mac OS X Python .
, Command+,
Terminal Enter.
Homebrew, :
ruby -e "$(curl -fsSkL [Link]/mxcl/homebrew/go)"
Python 3 :
brew install python3
python3 -V , .
5.3. Mac OS X
25
5.4
GNU/Linux BSD, , Python . , ,
. Windows Python
. , Python 3
.
Python.
26
5.
6.1
, Hello World Python.
, Python.
Python:
.
, .
6.2
( ) Python, python3 Enter.
Windows , PATH .
Windows, . cmd Enter;
python DOS.
IDLE, Python 3.0 IDLE
(Python GUI).
python3, >>> ,
- . Python
print('Hello World') Enter.
Hello World.
, ,
Mac OS X. Python ,
, (.. >>> )
.
27
$ python3
Python 3.3.0 (default, Oct 22 2012, 12:20:36)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> print('hello world')
hello world
>>>
, Python !
Python. print , ( 1 ) .
Hello World, .
:
IDLE GNU/Linux BSD, Ctrl-D exit() (: , ()), Enter.
Windows, Ctrl-Z, Enter.
6.3
, - ,
, .
Python ,
. .
, . Python, ,
.
,
Python ,
.
, ,
Komodo Edit, Windows, Mac OS X GNU/Linux.
Windows, , ,
, , .
, Komodo Edit, .
, , Vim Emacs.
, , 1
28
print - . (. .)
6.
6.4
. ,
,
, !. , , !. Simon Cozens2 , , .
,
[Link]
Komodo Edit, , :
print(', !')
Komodo Edit .
? , . , , Python:
C:\\py Windows
/tmp/py GNU/Linux
/tmp/py Mac OS X
2
Beginning Perl
6.4.
29
- Komodo Edit, :
1. , .
2. , . , cd /tmp/py.
3. , python3 [Link].
30
6.
, !
Python. , !
,
, , . , Python
, print , Print (
p P ).
,
, .
Python . .
print, ', !'. , , ,
, .
', !'.
6.4.1 Python
GNU/Linux Unix, Windows
.
, Python,
python3 [Link]. ,
? hashbang.
, , :
#!/usr/bin/env python3
:
#!/usr/bin/env python3
print(', !')
,
chmod, .
chmod 3
4 .
3
ange mode - . (. .)
a all (. ), x execute (.
) . .
4
6.4.
31
, /usr/bin/env, , , Python 3, ,
.
$ ./[Link]
, !
./ , .
helloworld
./helloworld, , , ,
.
. , ? , ,
PATH.
- , PATH, . , , ,
PATH.
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/swaroop/bin
$ cp [Link] /home/swaroop/bin/helloworld
$ helloworld
, !
6.
6.5
Python
help.
. , help(print)
print, .
: q.
Python.
help() help!
, , return,
(, help('return')), Python , .
6.6
, Python.
Python,
.
6.5.
33
34
6.
, ! , ?
- , . Python
,
, .
7.1
, #,
.
:
print(', !) # print --
:
# print --
print(', !)
, :
;
;
;
, ;
, ..
, , , .
, ,
, . ,
!
35
7.2
, , 5, 1.23, 9.25e-3
- ' ' "It's a string!". ,
1 . 2
, . .
7.3
Python : , .
2.
( )
3.23 52.3E-4. E 10.
52.3E-4 52.3 104 .
: (-5+4j) (2.3 - 4.6j)
long int ( ).
.
7.4
.
.
, ,
Unicode, .
Python 3 ASCII-, Unicode (
) ASCII. ASCII,
[Link]("ascii"). StackOverow.
Unicode.
, Python. ,
Python.
1
36
literal . ; (. ). (. .)
7.
7.4.1
, , , ' '. , .
7.4.2
, . ,
"What's your name?".
7.4.3
("""
''').
. :
''' . .
.
"What's your name?", - .
: "Bond, James Bond."
'''
7.4.4
, .
, .
, .
7.4.5
, Python . , 'What\'s ' 'your name?' "What's your
name?".
C/C++
Python char (). , ,
.
Perl/PHP
, ,
.
7.4.
37
7.4.6 format
- . - format().
str_format.py:
age = 26
name = 'Swaroop'
print(' {0} -- {1} .'.format(name, age))
print(' {0} Python?'.format(name))
:
$ python str_format.py
Swaroop -- 26 .
Swaroop Python?
:
,
format .
, {0},
name,
format. , {1} age,
format. , Python 0, 0, 1 ..
,
: '' + name + ' -- ' + str(age) + ' .',
, , . , format ,
. -,
format, ,
, .
, .
:
age = 26
name = 'Swaroop'
print(' {} -- {} .'.format(name, age))
print(' {} Python?'.format(name))
, .
format Python .
, :
38
7.
>>> # (.) 3 :
... '{0:.3}'.format(1/3)
'0.333'
>>> # (_) (^) 11:
... '{0:_^11}'.format('hello')
'___hello___'
>>> # :
... '{name} {book}'.format(name='Swaroop', book='A Byte of Python')
'Swaroop A Byte of Python'
Python
PEP 3101.
7.5
. .
, , , .
, .
, - ,
.
7.6
. , - . :
( ASCII
, Unicode), (_).
( ASCII
, Unicode), (_)
(0-9).
. , myname myName
. n
N .
: i, __my_name, name_23, a1b2_c3 __utf8_.
: 2things, , myname, >a1b2_c3 "__".
7.5.
39
7.7
, . , .
, .
7.8
, Python , , . ,
. , , .
-
Python , ,
, .
, . .
Python
Python :
1. , Komodo Edit.
2. .
3. , .
Python .py.
4. python3 [Link]. ,
, .
7.8.1 :
# : [Link]
i = 5
print(i)
i = i + 1
print(i)
s = ''' .
.'''
print(s)
40
7.
:
. 5 i, (=). ,
, i
5. i, print,
.
1 , i .
6, .
s,
.
. /.
7.9
, , . , Python . Python ,
.
print(', !') ( ),
.
Python , .
, (;),
/. ,
i = 5
print(i)
,
7.9.
41
i = 5;
print(i);
i = 5; print(i);
i = 5; print(i)
.
. ,
Python.
,
. , , .
.
s = ' . \
.'
print(s)
:
. .
,
print\
(i)
,
print(i)
, . , , , .
. .
7.10
Python . , . . ( ) -
42
7.
, :
File "[Link]", line 4
print(' ', i) # !
^
IndentationError: unexpected indent
, . , Python, , , ..
. ,
( , , ). , , , ,
.
, .
.
- . , ,
. .. , ,
, ,
, .
, Komodo Edit, .
Python . from __future__ import braces, .
7.10.
43
7.11
, ,
.
.
44
7.
( ) . : 2 + 3. .
, - , , +, . ,
. 2 3 .
8.1
:
, , , . , 2 + 3
Python:
>>> 2 + 3
5
>>> 3 * 5
15
+
-
3 + 5 8; 'a' + 'b'
'ab'
-5.2
, 50 - 24 26.
;
,
,
.
2 * 3 6. 'la' * 3
'lalala'.
45
**
/
//
<<
>>
&
46
,
y
3 ** 4 81 (.. 3 * 3 * 3
* 3)
x y
4 / 3
1.3333333333333333.
4 // 3 1.
8 % 3 2. -25.5 % 2.25
1.5.
. (
, .. 0 1)
.
2 << 2 8.
2 10.
2
1000,
8.
11 >> 1 5.
11
1011,
1 , 101, ,
,
5
5 & 3 1.
5 | 3 7
5 ^ 3 6
x -(x+1)
~5 -6.
8.
<
>
<=
>=
==
!=
not
and
, , x
y.
True
False 1 .
.
, , x
y
5 < 3 False,
3 < 5 True.
, , x
y
: 3 < 5 < 7
True.
5 > 3 True.
- ,
.
False.
x = 3; y = 6; x <= y
True.
, , x
y
x = 4; y = 3; x >= 3
True.
, ,
x True,
False. x
False, True.
x and y False, x
False ,
y
x = 2; y = 2; x == y
True. x = 'str'; y = 'stR';
x == y False. x = 'str';
y = 'str'; x == y True.
x = 2; y = 3; x != y
True.
x = True; not x False.
Python
y, ,
and False,
,
False,
.
() .
1
8.1.
47
or
x True,
True,
y
x = True; y = False; x or y
True.
8.1.1 .
, .
:
:
a = 2; a = a * 3
:
a = 2; a *= 3
, = = .
8.2
2 + 3 * 4, : ? ,
. , , .
Python, ( ) ( ).
, Python , , .
Python (.) .
, . . .
.
48
8.
lambda
or
and
not x
in, not in
is, is not
<, <=, >, >=, !=, ==
|
^
&
<<, >>
+, *, /, //, %
+x, -x
~x
**
[Link]
x[]
x[1:2]
f( ...)
(, ...)
[, ...]
{:, ...}
, ,
,
, , .
. , + - .
8.3
. , 2 + (3 * 4)
, 2 + 3 * 4, .
, ( )
, (2 + (3 * 4)).
. , , (2 + 3) * 4.
2
tuple - . (. .)
8.3.
49
8.4
. ,
. , 2 + 3 + 4
(2 + 3) + 4. , , , , , .. a = b = c a = (b
= c).
8.5
( [Link]):
length = 5
breadth = 2
area = length * breadth
print(' ', area)
print(' ', 2 * (length + breadth))
:
$ python [Link]
10
14
:
length breadth
.
. length *
breadth area, print. 2 * (length + breadth) print.
, Python .
, ' ' area,
Python , .
( , ). ,
Python .
8.6
, , .
. , .
50
8.
, ,
Python . , ? , , ; ,
.
, , , . Python : if, for while.
9.1 if
if : 1 2 ,
( if-), 3 ( else-). else .
: ( [Link])
number = 23
guess = int(input(' : '))
if guess == number:
print(', ,') #
print('( !)') #
elif guess < number:
print(', .') #
# , ...
else:
print(', .')
# , guess , number
print('')
# if
1
if . (..)
True (..)
3
else . , (..)
2
51
$ python [Link]
: 22
, .
$ python [Link]
: 23
, ,
( .)
:
,
. number , . , 23.
input(). -
. .
input ,
. -
Enter, input() , . int(),
guess. -, int ,
,
(,
).
, , ,
. , . , ,
Python, . Python. ,
, ?
, if , .
, ,
, , ,
. 52
9.
, Python if
elif else, , if.
( ),
print(''). Python
.
, ,
. ( ,
C/C++). ,
, .
C/C++
Python switch. , if..elif..else
( ,
).
9.2 while
while , . .
else.
: ( [Link])
number = 23
running = True
4
nested . (..)
9.2. while
53
while running:
guess = int(input(' : '))
if guess == number:
print(', .')
running = False # while
elif guess < number:
print(', ')
else:
print(', .')
else:
print(' while .')
#
print('.')
:
$ python [Link]
: 50
, .
: 22
, .
: 23
, .
while .
.
:
, , ,
,
, .
while.
input if while running True . , running True, while-.
, running,
. , while- ,
else-,
.
else , while (False)
. while
else, ,
break.
54
9.
C/C++
, while else.
9.3 for
for..in ,
, .. . ,
, .
: ( [Link])
for i in range(1, 5):
print(i)
else:
print(' for ')
:
$ python [Link]
1
2
3
4
for
:
. , range5 .
, range . , range(1,5) [1, 2,
3, 4]. range , 1.
range, . ,
range(1,5,2) [1,3]. ,
, .. .
, range() ,
for . , list(range()). 6
5
6
range . , (..)
list . (..)
9.3. for
55
9.4 break
break 7 , .. False .
, for while break, else .
: ( [Link])
while True:
s = input(' - : ')
if s == '':
break
print(' : ', len(s))
print('')
:
7
56
break . , (..)
9.
$ python [Link]
-
: 23
-
: 19
-
: 30
-
: 23
-
: .
: ,
: :
Python!
:
.
, ,
''.
break .
len.
, break for.
9.4. break
57
9.5 continue
continue Python,
9 .
: ( [Link])
while True:
s = input(' - : ')
if s == '':
break
if len(s) < 3:
print(' ')
continue
print(' ')
# ...
:
$ python [Link]
- : a
- : 12
- :
- :
:
, 3 .
, len ,
3, continue.
, , .
, continue for.
9.6
, : if, while
for, break continue. Python, .
, .
9
58
continue . (..)
9.
.
,
.
. , len range.
, ,
( ),
.
def.
, ,
, . , . ,
:
: ( [Link])
def sayHello():
print(', !') # ,
#
sayHello() #
sayHello() #
:
$ python [Link]
, !
, !
:
sayHello,
. , - .
, , .
,
, .
59
10.1
, .. ,
, - . ,
, ,
.
.
, .
: , , , , , .
: ( func_param.py)
def printMax(a, b):
if a > b:
print(a, '')
elif a == b:
print(a, '', b)
else:
print(b, '')
printMax(3, 4) #
x = 5
y = 7
printMax(x, y) #
:
$ python func_param.py
4
7
:
printMax,
a b.
if..else .
printMax .
. printMax(x, y) x a, y b.
printMax .
60
10.
10.2
, ..
. . , , .
: ( func_local.py)
x = 50
def func(x):
print('x ', x)
x = 2
print(' x ', x)
func(x)
print('x ', x)
:
$ python func_local.py
x 50
x 2
x 50
:
, x, Python , ,
.
x 2. x . x , x,
, .
print x, , , .
10.3 global
,
(.. - , ), Python, , (global). global. global
, .
10.2.
61
:
$ python func_global.py
x 50
x 2
x 2
:
global , , x
, , x , x
.
global,
: global x, y, z.
10.4 nonlocal
, . , (nonlocal)
, . ,
.
Python ,
.
62
10.
:
$ python func_nonlocal.py
x 2
x 5
:
func_inner, x, func_outer ( func_inner), ( ). , x, : nonlocal
x.
nonlocal x global x, ,
.
10.5
, ,
. .
, (=) .
, .
, 1 . .
1
immutable Python (. .)
10.5.
63
:
$ python func_default.py
:
say
. ,
. ,
1 times2 .
say ,
. say 5,
, 3 5 .
: , . ,
. ,
. , def func(a, b=5) , def func(a=5, b) .
10.6
, ,
.
() ( ).
: -,
, ; -,
, , .
: ( func_key.py)
2
3
64
times . (. .)
say . (. .)
10.
:
$
a
a
a
python func_key.py
3, b 7, c 10
25, b 5, c 24
100, b 5, c 50
:
func ,
.
, func(3, 7), a 3, b
7, c , 10.
func(25, c=24) a 25
. c 24 ,
.. . b ,
5.
func(c=50, a=100) . , c a,
, a c.
10.7
, . ( [Link]):
def total(initial=5, *numbers, **keywords):
count = initial
for number in numbers:
count += number
for key in keywords:
count += keywords[key]
return count
print(total(10, 1, 2, 3, vegetables=50, fruits=100))
4
10.7.
65
:
(, *param),
param.
, (**param),
param.
.
10.8
,
, (
keyword_only.py):
def total(initial=5, *numbers, extra_number):
count = initial
for number in numbers:
count += number
count += extra_number
print(count)
total(10, 1, 2, 3, extra_number=50)
total(10, 1, 2, 3)
# ,
# 'extra_number'.
:
$ python keyword_only.py
66
Traceback (most recent call last):
File "keyword_only.py", line 12, in <module>
total(10, 1, 2, 3)
TypeError: total() needs keyword-only argument extra_number
:
. ,
, ,
.
66
10.
10.9 return
return 5 , ..
. .
: ( func_return.py)
#!/usr/bin/python
# Filename: func_return.py
def maximum(x, y):
if x > y:
return x
elif x == y:
return ' .'
else:
return y
print(maximum(2, 3))
:
$ python func_return.py
3
:
maximum ,
.
if..else ,
.
, return return None. None Python, . , None, ,
.
return None ,
return. ,
5
return . (. .)
10.9. return
67
pass Python .
: max, , , .
10.10
Python , ,
docstrings. , , . , ,
, , !
: ( func_doc.py)
def printMax(x, y):
''' .
.'''
x = int(x) # ,
y = int(y)
if x > y:
print(x, '')
else:
print(y, '')
printMax(3, 5)
print(printMax.__doc__)
:
$ python func_doc.py
5
.
.
6
68
10.
10.11
, , ,
. Python
- ( ), .
, PEP 3107.
10.12
, , , . , ,
Python.
7
.. , . (. )
10.11.
69
70
10.
, , . ,
? , , , .
,
.py, .
,
Python. , C,
Python.
,
. Python. ,
.
: ( using_sys.py)
import sys
print(' :')
for i in [Link]:
print(i)
print('\n\n PYTHONPATH ', [Link], '\n')
:
$ python3 using_sys.py we are arguments
:
using_sys.py
we
are
arguments
PYTHONPATH ['', 'C:\\Windows\\system32\\[Link]',
'C:\\Python30\\DLLs', 'C:\\Python30\\lib',
'C:\\Python30\\lib\\plat-win', 'C:\\Python30',
'C:\\Python30\\lib\\site-packages']
71
, (. .)
IDE - . Integrated Development Environment (. -
.)
3
we are arguments - . (. .)
(. .)
4
72
11.
11.1 .pyc
, Python .
- ( ) .pyc,
, Python (
, Python?). .pyc
, , , .
-.
: .pyc , .py. Python
, .pyc .
11.1. .pyc
")
73
if ( i <= sqrt(a)):
if (a % i == 0):
print("a neprost",a)
b = 1
else:
pass
if (b != 1):
print("a prost",a)
p = p + [a]
count = count + 1
a = a + 2
print p
11.3 __name__
, . , , . , ,
. , - ,
. __name__.
: ( using_name.py)
if __name__ == '__main__':
print(' .')
else:
print(' .')
:
$ python3 using_name.py
.
$ python3
>>> import using_name
.
>>>
:
Python __name__5 .
'__main__', , ,
.
5
74
name - . (. .)
11.
11.4
. ! Python . , .py. .
: ( [Link])
def sayhi():
print('! .')
__version__ = '0.1'
# [Link]
. ,
Python. , .
, , , , , [Link].
( mymodule_demo.py):
import mymodule
[Link]()
print ('', mymodule.__version__)
:
$ python mymodule_demo.py
! .
0.1
:
, . Python , Python-
-.
, from..import ( mymodule_demo2.py):
from mymodule import sayhi, __version__
sayhi()
print('', __version__)
mymodule_demo2.py , mymodule_demo.py.
11.4.
75
, sayhi, __version__,
Python
Python . import this, , ,
.
11.5 dir
dir, , . ,
, .
dir() , , . , ,
.
:
$ python3
>>> import sys # 'sys'
>>> dir(sys)
['__displayhook__', '__doc__', '__excepthook__', '__name__', '__package__', '__s
tderr__', '__stdin__', '__stdout__', '_clear_type_cache', '_compact_freelists',
'_current_frames', '_getframe', 'api_version', 'argv', 'builtin_module_names', '
byteorder', 'call_tracing', 'callstats', 'copyright', 'displayhook', 'dllhandle'
, 'dont_write_bytecode', 'exc_info', 'excepthook', 'exec_prefix', 'executable',
'exit', 'flags', 'float_info', 'getcheckinterval', 'getdefaultencoding', 'getfil
esystemencoding', 'getprofile', 'getrecursionlimit', 'getrefcount', 'getsizeof',
'gettrace', 'getwindowsversion', 'hexversion', 'intern', 'maxsize', 'maxunicode
', 'meta_path', 'modules', 'path', 'path_hooks', 'path_importer_cache', 'platfor
m', 'prefix', 'ps1', 'ps2', 'setcheckinterval', 'setprofile', 'setrecursionlimit
', 'settrace', 'stderr', 'stdin', 'stdout', 'subversion', 'version', 'version_in
76
11.
:
dir
sys. , .
dir, . , . ,
.
dir,
a , dir. ,
. / del,
dir.
del: /, , del a,
a .
, dir() . , dir('print'), print,
dir(str), str.
11.6
, , . . . , ? - .
__init__.py,
Python, , Python.
11.6.
77
. .
11.7
, , . . Python .
, .
,
.
78
11.
, , ,
. , .
Python : , ,
. , , .
12.1
1 , , ..
. ,
, , , ,
,
Python .
, Python ,
. , ,
. , ,
, .. .
12.2
,
, .
.
.
i , , 5,
(.. ) i (.. ) int. ,
help(int).
, .. ,
. . , Python append list,
. [Link]('and item')
1
list . (..)
79
:
$ python3 using_list.py
4 .
:
.
: ['', '', '', '', '']
-
: ['', '', '', '',
'']
, ,
: ['', '', '', '']
:
80
12.
12.3
.
, ,
. , , , . .. .
, ;
.
, , , .. , .
: ( using_tuple.py)
zoo = ('', '', '') # ,
print(' -', len(zoo))
12.3.
81
:
$ python3 using_tuple.py
- 3
- 3
: ('', '', ('', '',
''))
, : ('', '', '')
, -
- 5
:
zoo . , len
. ,
.
,
. new_zoo , , . , , .
,
, . .
new_zoo , new_zoo[2],
new_zoo new_zoo[2][2].
, .
, , , , . ,
print(1,2,3) print( (1,2,3) ) :
, , .
, 0 1
myempty = (). ,
. 82
12.
12.4
, , ; .. ()
(). ,
, .
,
( ),
, . ,
.
- : d = {key1 : value1,
key2 : value2 }. , ,
, .
, - .
, .
/ dict.
: ( using_dict.py)
# 'ab' - 'a'ddress'b'ook
ab = {
'Swaroop'
'Larry'
'Matsumoto'
'Spammer'
:
:
:
:
'swaroop@[Link]',
'larry@[Link]',
'matz@[Link]',
'spammer@[Link]'
}
print(" Swaroop':", ab['Swaroop'])
# -
12.4.
83
del ab['Spammer']
print('\n {0} \n'.format(len(ab)))
for name, address in [Link]():
print(' {0} {1}'.format(name, address))
# -
ab['Guido'] = 'guido@[Link]'
if 'Guido' in ab:
print("\n Guido:", ab['Guido'])
:
$ python3 using_dict.py
Swaroop': swaroop@[Link]
3
Swaroop swaroop@[Link]
Matsumoto matz@[Link]
Larry larry@[Link]
Guido: guido@[Link]
:
ab2 , .
-, , . ,
.
-
del. , del.
,
.
- , items, ,
: . name address for..in,
for.
-
, Guido .
2
84
address book . (. .)
12.
12.5
, . ?
(.. in not in)
, .
, (, ),
, , .. .
: ( [Link])
shoplist = ['', '', '', '']
name = 'swaroop'
#
print(' 0 -', shoplist[0])
print(' 1 -', shoplist[1])
print(' 2 -', shoplist[2])
print(' 3 -', shoplist[3])
print(' -1 -', shoplist[-1])
print(' -2 -', shoplist[-2])
print(' 0 -', name[0])
#
print(' 1 3:', shoplist[1:3])
print(' 2 :', shoplist[2:])
print(' 1 -1:', shoplist[1:-1])
print(' :', shoplist[:])
#
12.5.
85
print('
print('
print('
print('
1 3:', name[1:3])
2 :', name[2:])
1 -1:', name[1:-1])
:', name[:])
:
$ python3 [Link]
0 -
1 -
2 -
3 -
-1 -
-2 -
0 - s
1 3: ['', '']
2 : ['', '']
1 -1: ['', '']
: ['', '', '', '']
1 3: wa
2 : aroop
1 -1: waroo
: swaroop
:
, ,
. . ,
, Python , . , Python 0.
shoplist[0] , shoplist[3]
shoplist.
. . shoplist[-1] shoplist, shoplist[-2]
.
, ,
. ,
, . ,
, .
( ) ,
, ( ) , . , Python
. ,
86
12.
, 2, , 0, 2, 3,
0, 3, ..
, Python, .. , .
, , !
12.6
. , ,
.
, , , ,
.
12.6.
87
:
, .
12.7
,
, !
, .
.
, , :
: ( [Link])
print(' ')
shoplist = ['', '', '', '']
mylist = shoplist # mylist - , !
del shoplist[0] # ,
print('shoplist:', shoplist)
print('mylist:', mylist)
# , shoplist, mylist
# "", , .
print(' ')
mylist = shoplist[:] #
del mylist[0] #
print('shoplist:', shoplist)
print('mylist:', mylist)
# ,
88
12.
:
$ python3 [Link]
shoplist: ['', '', '']
mylist: ['', '', '']
shoplist: ['', '', '']
mylist: ['', '']
:
.
, , ( ,
), . ,
, , .
12.8
. ? ,
, , ,
:
?
, , str. . , help(str).
: ( str_methods.py)
name = 'Swaroop' #
if [Link]('Swa'):
print(', "Swa"')
if 'a' in name:
print(', "a"')
if [Link]('war') != -1:
print(', "war"')
delimiter = '_*_'
12.8.
89
:
$ python3 str_methods.py
, "Swa"
, "a"
, "war"
_*__*__*_
:
. startswith
, , .
in , .
find ; find -1, . str
(join)3
, , .
12.9
Python. .
, Python, ,
Python.
90
join . (..)
12.
Python, ,
, , - .
, Python .
13.1
: ,
.
, , .
. , , ? ? ?
. ,
, .
, . , , -,
.
1. , , .
2. .
3. zip-.
4. zip- .
5. zip,
GNU/Linux. Windows
GnuWin32 C:\Program Files\GnuWin32\bin PATH, , python. ,
, ,
.
91
13.2
- , , .
backup_ver1.py:
import os
import time
# 1. , , .
source = ['"C:\\My Documents"', 'C:\\Code']
# , , ,
# .
# 2. .
target_dir = 'E:\\Backup' # , .
# 3. zip-.
# 4. zip- .
target = target_dir + [Link] + [Link]('%Y%m%d%H%M%S') + '.zip'
# 5. "zip" zip-
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
#
if [Link](zip_command) == 0:
print(' ', target)
else:
print(' ')
:
$ python3 backup_ver1.py
E:\\Backup\\[Link]
, , . , , ()1 , .. () .
, print(zip_command)
[Link] . zip_command , ,
. ,
1
debug (
, bug, .. ). ,
, bug
, , 1878 .
(. .)
92
13.
source . (..)
Unix ,
Unix, .
GNU/Linux, *BSD, Android, Solaris .. (..)
4
quietly . (..)
5
recursive . (..)
3
13.2.
93
13.3
. , ,
.
.
, , : ,
, , . ,
, .
, . , , ,
.
backup_ver2.py:
6
94
raw . , (.)
13.
import os
import time
# 1. , , .
source = ['"C:\\My Documents"', 'C:\\Code']
# , , ,
# .
# 2. .
target_dir = 'E:\\Backup' # , .
# 3. zip-.
# 4.
today = target_dir + [Link] + [Link]('%Y%m%d')
# zip-
now = [Link]('%H%M%S')
# ,
if not [Link](today):
[Link](today) #
print(' ', today)
# zip-
target = today + [Link] + now + '.zip'
# 5. "zip" zip-
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
#
if [Link](zip_command) == 0:
print(' ', target)
else:
print(' ')
:
$ python3 backup_ver2.py
E:\\Backup\\20080702
E:\\Backup\\20080702\\[Link]
$ python3 backup_ver2.py
E:\\Backup\\20080702\\[Link]
:
. ,
, , ,
. 13.3.
95
13.4
. , , , . , - , zip-.
zip-.
: , , , .
backup_ver3.py
import os
import time
# 1. , , .
source = ['"C:\\My Documents"', 'C:\\Code']
# , , ,
# .
# 2. .
target_dir = 'E:\\Backup' # , .
# 3. zip-.
# 4.
today = target_dir + [Link] + [Link]('%Y%m%d')
# zip-
now = [Link]('%H%M%S')
#
comment = input(' --> ')
if len(comment) == 0: # ,
target = today + [Link] + now + '.zip'
else:
target = today + [Link] + now + '_' +
[Link](' ', '_') + '.zip'
# ,
if not [Link](today):
[Link](today) #
print(' ', today)
96
13.
# 5. "zip" zip-
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
#
if [Link](zip_command) == 0:
print(' ', target)
else:
print(' ')
:
$ python3 backup_ver3.py
File "backup_ver3.py", line 25
target = today + [Link] + now + '_' +
^
SyntaxError: invalid syntax
() :
! Python , , , Python. Python , .
.
, , , , . Python
(+)
, , . , ,
. .
7 .
13.5
backup_ver4.py
import os
import time
# 1. , , .
source = ['"C:\\My Documents"', 'C:\\Code']
# , , ,
7
13.5.
97
# .
# 2. .
target_dir = 'E:\\Backup' # , .
# 3. zip-.
# 4.
today = target_dir + [Link] + [Link]('%Y%m%d')
# zip-
now = [Link]('%H%M%S')
#
comment = input(' --> ')
if len(comment) == 0: # ,
target = today + [Link] + now + '.zip'
else:
target = today + [Link] + now + '_' + \
[Link](' ', '_') + '.zip'
# ,
if not [Link](today):
[Link](today) #
print(' ', today)
# 5. "zip" zip-
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
#
if [Link](zip_command) == 0:
print(' ', target)
else:
print(' ')
:
$ python3 backup_ver4.py
--> added new examples
E:\Backup\20080702\202836_added_new_examples.zip
$ python3 backup_ver4.py
-->
E:\Backup\20080702\[Link]
:
! , 3.
input, , 98
13.
13.6
, . , 8 , -v
.
.
[Link] source extend list.
[Link] ,
zipfile tarfile. , zip .
[Link]
,
, , - .
ziple
[Link].
13.7
.
:
()
()
8
verbosity . .
, .. .
(.)
13.6.
99
13.8
, / Python,
.
, ,
Python, .
- .
100
13.
, .. , . - . :
. - .
, , - .
- . , . , int, , ,
, () int.
, ( int),
C++ Java ( 1.5), . .
help(int) . C# Java 1.5
1 .
, . , , .
, .. , . . ,
,
. ( ) .
: . .
class.
1
101
14.1 self
: , . , Python. , self2 .
,
self; . : -, , , ; -, (IDE) self.
C++, Java C#
self Python this C++ this Java C#.
, , , Python self
. . ,
MyClass myobject. , , [Link](arg1, arg2), Python [Link](myobject, arg1, arg2)
self.
, - , self.
14.2
( [Link]).
class Person:
pass #
p = Person()
print(p)
:
$ python3 [Link]
<__main__.Person object at 0x019F85F0>
:
2
self . (..)
102
14. -
14.3
, / ,
, self. ( [Link]).
class Person:
def sayHi(self):
print('! ?')
p = Person()
[Link]()
# Person().sayHi()
:
$ python3 [Link]
! ?
:
self . , sayHi
, , self .
14.4
__init__
, Python.
__init__.
__init__ , .
, . .
: ( class_init.py)
14.3.
103
class Person:
def __init__(self, name):
[Link] = name
def sayHi(self):
print('! ', [Link])
p = Person('Swaroop')
[Link]()
# Person('Swaroop').sayHi()
:
$ python3 class_init.py
! Swaroop
:
__init__ , name
( self). name. , , ,
name. , [Link]
, name, self, name .
, , .
,
__init__ ,
. .
[Link]
, sayHi.
14.5
(.. ) ,
. , .. , ,
, . ,
.
.
: , , .
. , ,
104
14. -
14.5.
105
droid2 = Robot('C-3PO')
[Link]()
[Link]()
print("\n - .\n")
print(" . .")
del droid1
del droid2
[Link]()
:
$ python3 [Link]
( R2-D2)
! R2-D2.
1 .
( C-3PO)
! C-3PO.
2 .
- .
. .
R2-D2 !
1 .
C-3PO !
C-3PO .
0 .
:
, . population Robot, . name (
self),
.
, population
[Link], [Link]. name
[Link].
. , ,
, () !
howMany , . , classmethod staticmethod, ,
, .
106
14. -
,
.
, __init__ Robot
. population 1,
. , [Link] ,
.
, ,
self. .
, . Robot.__doc__,
[Link].__doc__.
__init__, __del__,
, , .. ,
. [Link] 1.
__del__ , ,
, .
, del, .
C++/Java/C#
Python ( ) (public),
(virtual).
: , , ,
__privatevar, Python (private).
, ,
; , /. , , Python
( ).
14.5.
107
14.6
- ,
. .
, ,
. :
, . , ,
, .
,
-
, .
SchoolMember, ,
, ..
(), .
. / -
SchoolMember, .
, , SchoolMember. ,
. , SchoolMember,
, , . , , ..
, .
, , , .
SchoolMember 3 .
Teacher Student 4 .
( [Link]).
class SchoolMember:
''' .'''
def __init__(self, name, age):
[Link] = name
[Link] = age
print('( SchoolMember: {0})'.format([Link]))
def tell(self):
3
4
, (..)
, - (..)
108
14. -
''' .'''
print(':"{0}" :"{1}"'.format([Link], [Link]), end=" ")
class Teacher(SchoolMember):
''' .'''
def __init__(self, name, age, salary):
SchoolMember.__init__(self, name, age)
[Link] = salary
print('( Teacher: {0})'.format([Link]))
def tell(self):
[Link](self)
print(': "{0:d}"'.format([Link]))
class Student(SchoolMember):
''' .'''
def __init__(self, name, age, marks):
SchoolMember.__init__(self, name, age)
[Link] = marks
print('( Student: {0})'.format([Link]))
def tell(self):
[Link](self)
print(': "{0:d}"'.format([Link]))
t = Teacher('Mrs. Shrividya', 40, 30000)
s = Student('Swaroop', 25, 75)
print() #
members = [t, s]
for member in members:
[Link]() # ,
:
$ python3 [Link]
( SchoolMember: Mrs. Shrividya)
( Teacher: Mrs. Shrividya)
( SchoolMember: Swaroop)
( Student: Swaroop)
:"Mrs. Shrividya" :"40" : "30000"
:"Swaroop" :"25" : "75"
:
, 14.6.
109
14.7
- , ,
.
, , .
.
. , ,
SchoolMember,
SchoolMember.
. , , ..
, .
5
110
14. -
14.7.
111
print() #
members = [t, s]
for member in members:
[Link]() # ,
:
$ python3 [Link]
( SchoolMember: Mrs. Shrividya)
( Teacher: Mrs. Shrividya)
( SchoolMember: Swaroop)
( Student: Swaroop)
:"Mrs. Shrividya" :"40" : "30000"
:"Swaroop" :"25" : "75"
:
tell SchoolMember , SchoolMember.
, Teacher Student ,
SchoolMember, .
14.8
, ,
.
- . Python , .
, / Python.
112
14. -
-
,
. , - , . input() print() .
str (). ,
rjust ,
. . help(str) .
/ . , ,
.
15.1
user_input.py:
def reverse(text):
return text[::-1]
def is_palindrome(text):
return text == reverse(text)
something = input(' : ')
if (is_palindrome(something)):
print(", ")
else:
print(", ")
:
$ python3 user_input.py
:
,
$ python3 user_input.py
:
,
113
$ python3 user_input.py
:
,
:
.
,
seq[a:b], a b. , , . 1, . , .. -1
.
input()
. , - . , input() .
. ,
.
, , . ,
, . ,
.
: ( )
( ), , , , , .. forbidden = (!, ?, ., ).
15.2
file, / read, readline
write . ,
. ,
close1 , Python, .
1
close . (.)
114
15. -
:
$ python3 using_file.py
.
,
Python!
:
open , .
('r'), ('w') ('a')2 . , , :
('t') ('b'). , help(open) .
open() .
write , close.
.
,
. readline .
2
15.2.
115
15.3 Pickle
Python pickle3 , Python , .
.
: ( [Link]):
import pickle
# ,
shoplistfile = '[Link]'
#
shoplist = ['', '', '']
#
f = open(shoplistfile, 'wb')
[Link](shoplist, f) #
[Link]()
del shoplist # shoplist
#
f = open(shoplistfile, 'rb')
storedlist = [Link](f) #
print(storedlist)
:
$ python3 [Link]
['', '', '']
:
3
pickle . , (..)
116
15. -
15.4
/,
pickle.
.
15.4.
117
118
15. -
,
. , ?
, ? .
, . Python
, .
16.1
print. , print
Print? . Python .
>>> Print(', !')
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
Print(', !')
NameError: name 'Print' is not defined
>>> print(', !')
, !
, NameError, ,
. .
16.2
- . trl-D , .
>>> s = input(' - --> ')
- -->
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
119
Python EOFError, ,
( Ctrl-D) , .
16.3
try..except1 .
try-,
except-.
: ( try_except.py)
try:
text = input(' - --> ')
except EOFError:
print(' EOF?')
except KeyboardInterrupt:
print(' .')
else:
print(' {0}'.format(text))
:
$ python3 try_except.py
- -->
# ctrl-d
EOF?
$ python3 try_except.py
- -->
.
# ctrl-c
$ python3 try_except.py
- -->
:
, /, try, / except. except , / . ,
.
1
try . (..)
120
16.
16.4
raise2 , /, , .
,
Exception.
: ( [Link])
class ShortInputException(Exception):
''' .'''
def __init__(self, length, atleast):
Exception.__init__(self)
[Link] = length
[Link] = atleast
try:
text = input(' - --> ')
if len(text) < 3:
raise ShortInputException(len(text), 3)
#
except EOFError:
print(' EOF?')
except ShortInputException as ex:
print('ShortInputException: -- {0}; \
, , {1}'.format([Link], [Link]))
else:
print(' .')
:
$ python3 [Link]
- -->
2
raise . (..)
16.4.
121
ShortInputException: -- 1; , , 3
$ python3 [Link]
- -->
.
:
. ShortInputException. : length, , atleast, ,
.
except ShortInputException, 3 ex,
/.
. except length atleast
.
:
3
as . (..)
122
16.
$ python3 [Link]
,
!! .
(: )
:
,
[Link], ( Python
). ctrl-c,
/ .
, KeyboardInterrupt,
. , ,
finally, .
16.6 with
try finally. , ,
with4 :
using_with.py:
with open("[Link]") as f:
for line in f:
print(line, end='')
:
, .
, open with
with open.
. , with. , open.
thele.
, , with thefile.__enter__, thefile.__exit__
.
, finally,
__exit__.
try..finally.
4
with . (..)
16.6. with
123
16.7
try..except try..finally. , .
Python.
124
16.
Python Python.
Python , ,
.
. Python
Library Reference , Python.
.
, . , Python.
17.1 sys
sys , . ,
[Link] .
, Python , ,
, , 3. sys .
>>> import sys
>>> sys.version_info
(3, 0, 0, 'beta', 2)
>>> sys.version_info[0] >= 3
True
:
sys version_info,
. . -
125
:
$ python2.7 [Link]
[Link]:
Python 3.0
RuntimeWarning)
$ python3 [Link]
:
, warnings . Python 3, .
17.2 logging
,
-, ,
, . - ?
logging.
use_logging.py:
import os, platform, logging
if [Link]().startswith('Windows'):
logging_file = [Link]([Link]('HOMEDRIVE'), \
[Link]('HOMEPATH'), \
'[Link]')
else:
logging_file = [Link]([Link]('HOME'), '[Link]')
print(" ", logging_file)
126
17.
[Link](
level=[Link],
format='%(asctime)s : %(levelname)s : %(message)s',
filename = logging_file,
filemode = 'w',
)
[Link](" ")
[Link]("- ")
[Link](" ")
:
$ python3 use_logging.py
C:\Users\swaroop\[Link]
[Link], :
2012-10-26 16:52:41,457 : DEBUG :
2012-10-26 16:52:41,474 : INFO : -
2012-10-26 16:52:41,475 : WARNING :
:
: os , platform (.. ) logging 1 .
,
[Link]() , ( . import platform;
help(platform)). Windows, ,
, , . ,
.
, .
[Link]() .
, , ,
.
logging , .
, , , , . , 1
log . , (..)
17.2. logging
127
17.3
. , , , .
Python.
17.4
Python. Python, .
, Python
.
128
17.
, Python.
, .
18.1
-, , ?
. , , .
>>> def get_error_details():
...
return (2, ' No2')
...
>>> errnum, errstr = get_error_details()
>>> errnum
2
>>> errstr
' No2'
, a, b = < >
.
(a, < >),
, :
>>>
>>>
1
>>>
[2,
a, *b = [1, 2, 3, 4]
a
b
3, 4]
, Python
:
>>>
>>>
>>>
(8,
a = 5; b = 8
a, b = b, a
a, b
5)
129
18.2
, . , __init__ __del__.
,
. , ,
x[] ( ,
), __getitem__(). , Python
list!
. .
__init__(self, )
__del__(sel)
__str__(sel)
__lt__(self, other)
__getitem__(self, key)
,
.
print str().
, (<).
(+, >,
..)
x[]
__len__(sel)
len()
-.
18.3
, . , . ,
, , . :
>>> flag = True
>>> if flag: print('')
, , . , ,
, .
, ,
.
130
18.
18.4 Lambda-
lambda
. lambda ,
, , .
: ( [Link])
points = [ { 'x' : 2, 'y' : 3 }, { 'x' : 4, 'y' : 1 } ]
[Link](key=lambda i : i['y'])
print(points)
:
$ python3 [Link]
[{'x': 4, 'y': 1}, {'x': 2, 'y': 3}]
:
, sort list key, ( ).
,
. , def ,
, -.
18.5
. , , ,
, 2, , 2. .
: ( list_comprehension.py)
listone = [2, 3, 4]
listtwo = [2*i for i in listone if i > 2]
print(listtwo)
:
$ python3 list_comprehension.py
[6, 8]
18.4. Lambda-
131
18.6
, , , * ** . ,
.
>>> def powersum(power, *args):
...
''' , .'''
...
total = 0
...
for i in args:
...
total += pow(i, power)
...
return total
...
>>> powersum(2, 3, 4)
25
>>> powersum(2, 10)
100
args *, , , args . **
/ .
, eval Python, . .
132
18.
>>> eval('2*3')
6
18.8 assert
assert , , . , , ,
, , assert .
, AssertionError.
>>> mylist = ['item']
>>> assert len(mylist)
>>> [Link]()
'item'
>>> mylist
[]
>>> assert len(mylist)
Traceback (most recent
File "<stdin>", line
AssertionError
>= 1
>= 1
call last):
1, in <module>
, assert .
,
.
18.9 repr
repr
. , eval(repr(object)) == object.
>>> i = []
>>> [Link]('item')
>>> repr(i)
"['item']"
>>> eval(repr(i))
['item']
>>> eval(repr(i)) == i
True
, repr
. __repr__ , ,
repr.
18.8. assert
133
18.10
: , (')?
, What's your name?. 'What's your
name?', Python , , .
- ,
.
. \' .
: 'What\'s your name?'.
"What's your name?", .. . , .
\\.
?
, .
\n. : \n . (\t). ,
.
, ,
, . :
" . \
."
" . .".
18.11
, , ,
, , r
R1 . , r" \n".
.
. ,
'\\1' r'\1'.
1
r . raw , (. .)
134
18.
18.12
,
Python, -, . ,
, - .
.
, Python.
18.12.
135
136
18.
, , , Python. , - Python, . ? ! : ?.
.
, , , ,
. , .
, ,
. - , , .
( !)
. , . pickle. ,
.
, Python.
;-). , . ,
.
, :
replace. .
137
19.1
Stack Overow Python, .
19.2
:
PLEAC
Rosea
Python java2s
Python ,
Python. Python.
Python.
19.3
Python
Python
Norvig
Python
StackOverow python
19.4
Python
Python
Python Python .
138
19.
19.5
Python Awaretek
19.6
PyVideo
19.7
- Python , ,
python-tutor .
, .
19.8
Python,
Python.
19.9
Python , . pip.
19.10
Python -
( )
Python. Python, , C, C++ .
Python :
Kivy
hp://[Link]
19.5.
139
19.11
wiki- GuiProgramming
Python.
,
Python. ,
, . -, , . -, , : Windows,
Mac GNU/Linux . -, GNU/Linux,
: KDE GNOME.
. 26 Python, 3, 1.
140
19.
19.12
: . , - ,
, .
CPython.
CPython, C
Python1 .
,
Python:
Jython
Python, Java. , Java Python .
IronPython
Python, .NET, .NET Python .
PyPy
Python, Python! , ,
( ,
C, Java C# )
Stackless Python
Python, .
, CLPython Common Lisp
IronMonkey IronPython JavaScript, (Ajax) Python JavaScript.
.
19.13 ( )
, - , - :
, A.M. Kuchling
1
19.12.
141
19.14
, , ! Python, ,
Python.
, - . !
142
19.
: FLOSS
20.1 Free/Libre and Open Source Software (FLOSS)
FLOSS , ,
. , .
, ,
Python , Python !
, , :
Linux. , , , GNU/Linux. Linux
. [Linux Kernel]
GNU. , 1983
. [GNU]
GNU/Linux. GNU Linux, Microso Windows. , GNU/Linux , GNU/Linux
. [Free GNU/Linux distributions]
Ubuntu. , Canonical. , ,
GNU/Linux. . ,
GNU/Linux CD!
. , Ubuntu , ,
. [Ubuntu]
LibreOce. ,
, ,
, . MS Word MS Powerpoint. 1
(..)
143
144
20. : FLOSS
:
21.1
, , .
21.1.1
Red Hat 9.0
Linux, Fedora Core 3 Linux.
KWord ( ).
21.1.2
DocBook XML Kate,
. OpenOce,
PDF,
HTML-.
, XEmacs DocBook
XML (), , .
anta+.
XSL, Fedora Core 3 Linux.
CSS , HTML-. (, Python),
.
MediaWiki . , // -.
ViewSourceWith Firefox, Vim, Vim .
145
21.1.3
Vim, Pandoc, Mac OS X.
21.2
hp://[Link]/about/
146
21. :
:
2.0 (20/10/2012)
Pandoc ,
Mediawiki
, , nonlocal
1.90 (04/09/2008)
3.5 !
Python 3.0
MediaWiki ()
1.20 (13/01/2005)
anta+ Fedora Core 3
. . DocBook.
1.15 (28/03/2004)
.
1.12 (16/03/2004)
.
1.10 (09/03/2004)
147
1.00 (08/03/2004)
.
0.99 (22/02/2004)
. .
0.98 (16/02/2004)
Python CSS
XHTML, --
0.97 (13/02/2004)
DocBook XML ().
.
0.93 (25/01/2004)
IDLE , Windows.
0.92 (05/01/2004)
.
0.91 (30/12/2003)
. .
148
22. :
0.60 (21/11/2003)
.
0.20 (20/11/2003)
.
0.15 (20/11/2003)
DocBook XML XEmacs.
0.10 (14/11/2003)
KWord.
149
150
22. :
hps://[Link]/swaroopch/byte_of_python .
Git-
.
. Git.
.pd . Pandoc README,
README , PDF ..
151