You are on page 1of 159

A Byte of Python (Russian)

2.01

Swaroop C H (Translated by Vladimir Smolyar)

22 August 2013

1.1 A Byte of Python -


1.2 A Byte of Python? . . . . . . . . . .
1.3 . . . . . . . . . . . . . . . . . . . . . . .
1.4 . . . . . . . . . . . . . . . . . . . . . . . . .
1.5 . . . . . . . . . . . . . . . . . . . .
1.6 . . . . . . . . . . . . . . . . . . . . . . . .
1.7 . . . . . . . . . .

.
.
.
.
.
.
.

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 Python.


Python
. , , .
Python 3, , Python 2
( . Python 2 3).

1.2 A Byte of Python?


:
, A Byte of Python . ,
.
Syed Talal (19 )
1

A Byte of Python ( ) - , A
Bite of Python (..)
2
e-mail:
v_2e@ukr.net

A Byte of Python (Russian), 2.01


, ! .
Walt Michalik (wmich50-at-theramp-dot-net)

Python , . .
!
Joshua Robin (joshrob-at-poczta-dot-onet-dot-pl)

#Python
Shan Rajasekaran

! . . A Byte of Python, :). . ,


Pavel Simo (pavel-dot-simo-at-gmail-dot-com)

A Byte of Python , . ,
OReilly - Python. .
Samuel Young (sy-one-three-seven-at-gmail-dot-com)

Swaroop, , , . Python, OReilly.


, - , , - .
. Python
. ! ,
, .
Joseph Duarte (jduarte1-at-c-dot-rr-dot-com)

! Python,
. ! ! !
Chris-Andr Sommerseth

1.

A Byte of Python (Russian), 2.01


, A Byte of Python.
Python , . pyGame, .
, Python . , -
.

. ,
, .
Ma Gallivan (m-underscore-gallivan12-at-hotmail-dot-com)

A byte of python, Python. 15 , . . Python . Visual Basic 6,


, Python - .
.
Python ( ).
Java, Java,
, , . .
Ahmed Mohammed (sedo-underscore-91-at-hotmail-dot-com)

, Python
A Byte of Python, Swaroop C H 110 . , , ,
Python
Drew Ames Scripting Scribus, Linux.com

Byte of Python Nokia N800,


Python , .
Python.
Jason Delport

Byte of Vim Python, @swaroopch, , . #FeelGoodFactor


Surendran
1.2. A Byte of Python?

A Byte of Python (Russian), 2.01


Byte of python
( Python.)
Justin LoveTrue Facebook

Byte of Python . , bigtime :)


Chinmay

A Byte of Python , .
Patrick Harrington, StackOverow

NASA
! 3 4 .

Vrije,

Python




3
4

Jet Propulsion Laboratory (..)


Deep Space Network (..)

1.

A Byte of Python (Russian), 2.01

1.3
Creative Commons AributionShare Alike 3.0 Unported.
, :
,


:
, .
hp://www.swaroopch.com/notes/Python
, .
/, , BSD5 , .

1.4
.

1.5
,
, ( ).

1.6
PDF-
EPUB ( ).

,
.
5

3-clause BSD license (..)

1.3.

A Byte of Python (Russian), 2.01

1.7
,
.

1.


,
.
, , .
, , , .

2.1
2.1.1
. Ashraf Ali Khalaf
.
sourceforge.net. . .

2.1.2
:
Samuel Dias Neto (samuel.arataca-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

A Byte of Python (Russian), 2.01


(
).
Python, Swaroop
. , . ,
.
,
. .
?
.
. , , .

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://code.google.com/p/zhpy/wiki/ByteOfZhpy .
8

2.

A Byte of Python (Russian), 2.01


,
Python Python.
Fred Lin:
Delta
Network. , - TurboGears.
Python (:-p) ,
Python. , A Byte of
Python . A Byte of Python Python
.

, .

Python,
zhpy, 2007 .
zhpy ( .. ) Python, Python . , , .

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://abop-german.berlios.de .
Lutz Horn :
32 , . - .
, , Java,
Python. Python. , -,
Java- Struts.
2.1.

A Byte of Python (Russian), 2.01


. Ruby .
, Python Ruby,
, , Java. -
, -.
How to ink Like a Computer Scientist: Learning with Python Dive into
Python. , . . A Byte of Python, ,
, ,
, , . , DocBook,
,
.
Bernd Hengelein :
.
,
.
. 34 , 1980-,
Commodore C64 . , , .
. , () , C++,
.
Python . -
, , Python, . , .
Python, , . ,
. , ,
. !

2.1.8
Ubuntu ),
Python .
@savvasradevic.

10

2.

A Byte of Python (Russian), 2.01

2.1.9
Daniel (daniel-dot-mirror-at-gmail-dot-com)
hp://python.or.id/moin.cgi/ByteofPython .
W. Priyambodo . hp://www.swaroopch.org/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) .
www.gentoo.it/Programmazione/byteofpython .
: hp://www.swaroopch.org/notes/Python_it:Prefazione .
Massimo Lucci Enrico Morelli:
() . (Massimo) , Enrico
/ . Python
, Linux . - www.gentoo.it Gentoo/Linux,
www.nmr.it ( )
. !
, , ,
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

A Byte of Python (Russian), 2.01


Eirik Vgeskar:
, , .
, , , . ,
. A Byte of Python
, , Python . ,
, . , , (, ), .

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://www.swaroopch.org/notes/Python_ro .
12

2.

A Byte of Python (Russian), 2.01

2.1.17
(v_2e-at-ukr-dot-net) .
hp://wombat.org.ua/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

A Byte of Python (Russian), 2.01


. . , A Byte
of Python Maximiliano Soler.
Cristian Bermudez Serna :
Antioquia (). Python , .

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

A Byte of Python (Russian), 2.01


, . , Python. . , , Python,
. , , .
Python (
) Red Hat Linux 9.0 KWord. ,
Python.
, 30 .
.
,
Python. .
Python,
, ,
:)
, , ,
, .

3.3
2012 , , Pandoc , .
2008 (
2005 ) , Python 3.0.
,
. , , ,
.

3.4 -
hp://www.swaroopch.com/notes/Python,
, ,
.

16

3.

A Byte of Python (Russian), 2.01

3.5
: ,
, ;
, , .
C. A. R. Hoare

, .
C. W. Wendte

3.5.

17

A Byte of Python (Russian), 2.01

18

3.


Python , . , , ,
.
Python :
Python .
,
, - . ,
,
.
.

, Python,
BBC 1 , ,
,
.

4.1 Python
4.1.1
Python . Python
, ! Python .
, .
1

Monty Pythons Flying Circus (..)

19

A Byte of Python (Russian), 2.01

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.

A Byte of Python (Russian), 2.01


, ,
. Python, , .. , Python , , !

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

A Byte of Python (Russian), 2.01


Python . ,
.

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. .

5.1 GNU/Linux BSD


GNU/Linux, Ubuntu, Fedora,
OpenSUSE, Debian, CentOS { }, BSD, ,
FreeBSD, , Python.
, Python BSD GNU/Linux, (, konsole gnome-terminal)
python -V, .
$ python -V
Python 3.3.0

: $ - . -
,
$.
, , Python .
:
$ python -V
bash: Python: command not found

, Python . , .
: Python 3.x, python3 -V.
Python:
Python . -.
23

A Byte of Python (Russian), 2.01


, , , , apt-get Ubuntu/Debian , Debian, yum Fedora, pkg_add FreeBSD, ..
, .
.

5.2 Windows
hp://www.python.org/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:\AUTOEXEC.BAT :
PATH=%PATH%;C:\Python33( ) . Windows NT AUTOEXEC.NT.
Windows Vista:
1.
2. ,
. , . .
. .
3. Path
.

24

5.

A Byte of Python (Russian), 2.01


4. , .
5. . Vista .
Windows 7:
1. ; . , .
PATH, .
2.
;C:\Python33.
3. %SystemRoot%\system32;,
%SystemRoot%\system32;C:\Python33

4. Ok, . .

5.2.2 Python Windows


PATH, .
Windows, .
cmd Enter.
python3 -V , .

5.3 Mac OS X
Mac OS X Python .
, Command+,
Terminal Enter.
Homebrew, :
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"

Python 3 :
brew install python3

python3 -V , .

5.3. Mac OS X

25

A Byte of Python (Russian), 2.01

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

A Byte of Python (Russian), 2.01

$ 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.

A Byte of Python (Russian), 2.01


Python.
, Vim.
Vim Emacs, . , ,
Komodo Edit Python, .
: Python .
Vim
Vim IDE
Python, John M Anderson. jedi-vim
.
Emacs
Emacs IDE
Python, Ryan McGuire. dotemacs
BG.

6.4
. ,
,
, !. , , !. Simon Cozens2 , , .
,
helloworld.py
Komodo Edit, , :
print(', !')

Komodo Edit .
? , . , , Python:
C:\\py Windows
/tmp/py GNU/Linux
/tmp/py Mac OS X
2

Beginning Perl

6.4.

29

A Byte of Python (Russian), 2.01


, mkdir . , mkdir
/tmp/py.
: .py. , file.py.
Komodo Edit , python3
helloworld.py . ,
.

- Komodo Edit, :
1. , .
2. , . , cd /tmp/py.
3. , python3 helloworld.py.
30

6.

A Byte of Python (Russian), 2.01


.
$ python3 helloworld.py
, !

, !
Python. , !
,
, , . , Python
, print , Print (
p P ).
,
, .

Python . .
print, ', !'. , , ,
, .
', !'.

6.4.1 Python
GNU/Linux Unix, Windows
.
, Python,
python3 foo.py. ,
? 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

A Byte of Python (Russian), 2.01

$ chmod a+x helloworld.py

, /usr/bin/env, , , Python 3, ,
.
$ ./helloworld.py
, !

./ , .
helloworld
./helloworld, , , ,
.

. , ? , ,
PATH.
- , PATH, . , , ,
PATH.
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/swaroop/bin
$ cp helloworld.py /home/swaroop/bin/helloworld
$ helloworld
, !

PATH echo, $, , . , /home/swaroop/bin


PATH, swaroop ,
. , , .
- PATH ,
PATH=$PATH:/home/swaroop/mydir, '/home/swaroop/mydir' ,
PATH.
, . , ,
cd , GNU/Linux DOS.
: Python, ()
.
32

6.

A Byte of Python (Russian), 2.01

6.5
Python
help.
. , help(print)
print, .
: q.
Python.
help() help!
, , return,
(, help('return')), Python , .

6.6
, Python.
Python,
.

6.5.

33

A Byte of Python (Russian), 2.01

34

6.


, ! , ?
- , . Python
,
, .

7.1
, #,
.
:
print(', !) # print --

:
# print --
print(', !)

, :
;
;
;
, ;
, ..
, , , .
, ,
, . ,
!

35

A Byte of Python (Russian), 2.01

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,
str.encode("ascii"). StackOverow.
Unicode.
, Python. ,
Python.
1

36

literal . ; (. ). (. .)

7.

A Byte of Python (Russian), 2.01

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

A Byte of Python (Russian), 2.01

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.

A Byte of Python (Russian), 2.01

>>> # (.) 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

A Byte of Python (Russian), 2.01

7.7
, . , .
, .

7.8
, Python , , . ,
. , , .
-
Python , ,
, .
, . .
Python
Python :
1. , Komodo Edit.
2. .
3. , .
Python .py.
4. python3 program.py. ,
, .

7.8.1 :
# : var.py
i = 5
print(i)
i = i + 1
print(i)
s = ''' .
.'''
print(s)

40

7.

A Byte of Python (Russian), 2.01


:
$ python var.py
5
6
.
.

:
. 5 i, (=). ,
, i
5. i, print,
.
1 , i .
6, .
s,
.

. /.

7.9
, , . , Python . Python ,
.
print(', !') ( ),
.
Python , .
, (;),
/. ,
i = 5
print(i)

,
7.9.

41

A Byte of Python (Russian), 2.01

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.

A Byte of Python (Russian), 2.01


, , , .
, , , . .
, .
,
. :
i = 5
print(' ', i) # !
print(' , ', i)

, :
File "whitespace.py", line 4
print(' ', i) # !
^
IndentationError: unexpected indent

, . , Python, , , ..
. ,
( , , ). , , , ,
.

, .
.
- . , ,
. .. , ,
, ,
, .
, Komodo Edit, .

Python . from __future__ import braces, .

7.10.

43

A Byte of Python (Russian), 2.01

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

A Byte of Python (Russian), 2.01

**

/
//

<<

>>

&

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.

A Byte of Python (Russian), 2.01

<

>

<=

>=

==

!=
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.

x = False; y = True; x and


y False,
x False.

Python
y, ,

and False,
,

False,

.

() .
1

True - . (); False - . (). (. .)

8.1.

47

A Byte of Python (Russian), 2.01

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.

A Byte of Python (Russian), 2.01


lambda
or
and
not x
in, not in
is, is not
<, <=, >, >=, !=, ==
|
^
&
<<, >>
+, *, /, //, %
+x, -x
~x
**
x.attribute
x[]
x[1:2]
f( ...)
(, ...)
[, ...]
{:, ...}


, ,
,



, , .
. , + - .

8.3
. , 2 + (3 * 4)
, 2 + 3 * 4, .
, ( )
, (2 + (3 * 4)).
. , , (2 + 3) * 4.
2

tuple - . (. .)

8.3.

49

A Byte of Python (Russian), 2.01

8.4
. ,
. , 2 + 3 + 4
(2 + 3) + 4. , , , , , .. a = b = c a = (b
= c).

8.5
( expression.py):
length = 5
breadth = 2
area = length * breadth
print(' ', area)
print(' ', 2 * (length + breadth))

:
$ python expression.py
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 .
: ( if.py)
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

A Byte of Python (Russian), 2.01


:
$ python if.py
: 50
, .

$ python if.py
: 22
, .

$ python if.py
: 23
, ,
( .)

:
,
. number , . , 23.

input(). -
. .
input ,
. -
Enter, input() , . int(),
guess. -, int ,
,
(,
).
, , ,
. , . , ,
Python, . Python. ,
, ?
, if , .
, ,
, , ,
. 52

9.

A Byte of Python (Russian), 2.01


elif, if
else-if else if-elif-else. , .
elif else ,
( , ).
if- if if
4 if.
, elif else . if :
if True:
print(', .')

, Python if
elif else, , if.
( ),
print(''). Python
.
, ,
. ( ,
C/C++). ,
, .
C/C++
Python switch. , if..elif..else
( ,
).

9.2 while
while , . .
else.
: ( while.py)
number = 23
running = True
4

nested . (..)

9.2. while

53

A Byte of Python (Russian), 2.01

while running:
guess = int(input(' : '))
if guess == number:
print(', .')
running = False # while
elif guess < number:
print(', ')
else:
print(', .')
else:
print(' while .')
#
print('.')

:
$ python while.py
: 50
, .
: 22
, .
: 23
, .
while .
.

:
, , ,
,
, .
while.
input if while running True . , running True, while-.
, running,
. , while- ,
else-,
.
else , while (False)
. while
else, ,
break.
54

9.

A Byte of Python (Russian), 2.01


True False , 1 0 .

C/C++
, while else.

9.3 for
for..in ,
, .. . ,
, .
: ( for.py)
for i in range(1, 5):
print(i)
else:
print(' for ')

:
$ python for.py
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

A Byte of Python (Russian), 2.01


.
for - for i in
range(1,5) for i in [1, 2, 3, 4], i ( ) ,
i.
.
, else . ,
for, break.
, for..in . , range,
!
.
C/C++/Java/C#
for Python for C/C++. C#
, for Python foreach C#. Java
for (int i : IntArray) Java 1.5.
C/C++ for (int i = 0; i < 5; i++), Python
for i in range(0,5). , Python for ,
.

9.4 break
break 7 , .. False .
, for while break, else .
: ( break.py)
while True:
s = input(' - : ')
if s == '':
break
print(' : ', len(s))
print('')

:
7

56

break . , (..)

9.

A Byte of Python (Russian), 2.01

$ python break.py
-
: 23
-
: 19
-
: 30
-
: 23
-

: .
: ,
: :

Python!

:
.
, ,
''.
break .
len.
, break for.

9.4.1 Python Swaroop


-, .
Python Swaroop8
.
,
Python!
8

Swaroops Poetic Python:


Programming is fun.
When the work is done,
if you wanna make your work also fun:
use Python!

9.4. break

57

A Byte of Python (Russian), 2.01

9.5 continue
continue Python,
9 .
: ( continue.py)
while True:
s = input(' - : ')
if s == '':
break
if len(s) < 3:
print(' ')
continue
print(' ')
# ...

:
$ python continue.py
- : a

- : 12

- :

- :

:
, 3 .
, len ,
3, continue.
, , .
, continue for.

9.6
, : if, while
for, break continue. Python, .
, .
9

58

continue . (..)

9.


.
,
.
. , len range.
, ,
( ),
.
def.
, ,
, . , . ,
:
: ( function1.py)
def sayHello():
print(', !') # ,
#
sayHello() #
sayHello() #

:
$ python function1.py
, !
, !

:
sayHello,
. , - .
, , .
,
, .
59

A Byte of Python (Russian), 2.01

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.

A Byte of Python (Russian), 2.01

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

A Byte of Python (Russian), 2.01


, ( ,
). , , , , , , . global ,
.
: ( func_global.py)
x = 50
def func():
global x
print('x ', x)
x = 2
print(' x ', x)
func()
print(' x ', x)

:
$ 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.

A Byte of Python (Russian), 2.01


:
# Filename: func_nonlocal.py
def func_outer():
x = 2
print('x ', x)
def func_inner():
nonlocal x
x = 5
func_inner()
print(' x ', x)
func_outer()

:
$ 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

A Byte of Python (Russian), 2.01


: ( func_default.py)
def say(message, times = 1):
print(message * times)
say('')
say('', 5)

:
$ 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 Byte of Python (Russian), 2.01

def func(a, b=5, c=10):


print('a ', a, ', b ', b, ', c ', c)
func(3, 7)
func(25, c=24)
func(c=50, a=100)

:
$
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

, . ( total.py):
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

VarArgs . Variable number of Arguments (. .)

10.7.

65

A Byte of Python (Russian), 2.01


:
$ python total.py
166

:
(, *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.

A Byte of Python (Russian), 2.01


+=, , x = x + y x +=
y.
, , ,
: def total(initial=5, *, extra_number).

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

A Byte of Python (Russian), 2.01


print(someFunction()), someFunction - , return . :
def someFunction():
pass

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

DocString - . Documentation String (. .)

10.

A Byte of Python (Russian), 2.01


:

. , ,
.
7 ,
. , .

.
printMax (.. , ) __doc__ ( ). , Python , . .
help() Python, . - __doc__
.
: help(printMax) .
q (help).
.
, . pydoc,
Python, help().

10.11
, , ,
. Python
- ( ), .
, PEP 3107.

10.12
, , , . , ,
Python.
7

.. , . (. )

10.11.

69

A Byte of Python (Russian), 2.01


, Python.

70

10.


, , . ,
? , , , .
,
.py, .
,
Python. , C,
Python.
,
. Python. ,
.
: ( using_sys.py)
import sys
print(' :')
for i in sys.argv:
print(i)
print('\n\n PYTHONPATH ', sys.path, '\n')

:
$ python3 using_sys.py we are arguments
:
using_sys.py
we
are
arguments
PYTHONPATH ['', 'C:\\Windows\\system32\\python30.zip',
'C:\\Python30\\DLLs', 'C:\\Python30\\lib',
'C:\\Python30\\lib\\plat-win', 'C:\\Python30',
'C:\\Python30\\lib\\site-packages']

71

A Byte of Python (Russian), 2.01


:
sys import.
Python, . sys ,
Python , .. (system).
Python import sys, sys.
, Python , .
, .. ,
Python, Python ,
sys.path. , , . , 1
.
argv sys ,
.. sys.argv. , sys.
, argv,
.
sys.argv ( ). , .. , .
2 ,
- .
, python using_sys.py we are
arguments, using_sys.py python, ,
, 3 . Python sys.argv .
, 4 sys.argv. 'using_sys.py'
sys.argv[0], 'we' sys.argv[1], 'are' sys.argv[2],
'arguments' sys.argv[3]. , Python
0, 1.
sys.path , .
, sys.path ; ,
sys.path,
PYTHONPATH. , ,
1
2

, (. .)
IDE - . Integrated Development Environment (. -

.)
3

we are arguments - . (. .)

(. .)
4

72

11.

A Byte of Python (Russian), 2.01


, . , sys.path.
, , . import os; print(os.getcwd()),
.

11.1 .pyc
, Python .
- ( ) .pyc,
, Python (
, Python?). .pyc
, , , .
-.
: .pyc , .py. Python
, .pyc .

11.2 from ... import ...


argv sys.
, from sys import argv.
, sys, from
sys import *. .

import,
.
:
from math import *
n = input(" :p = [2, 3]
count = 2
a = 5
while (count < n):
b=0
for i in range(2,a):

11.1. .pyc

")

73

A Byte of Python (Russian), 2.01

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.

A Byte of Python (Russian), 2.01

11.4
. ! Python . , .py. .
: ( mymodule.py)
def sayhi():
print('! .')
__version__ = '0.1'
# mymodule.py

. ,
Python. , .
, , , , , sys.path.
( mymodule_demo.py):
import mymodule
mymodule.sayhi()
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

A Byte of Python (Russian), 2.01


, , , __version__, . ,
.
import,
.
:
from mymodule import *

, 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.

A Byte of Python (Russian), 2.01

fo', 'warnoptions', 'winver']


>>> dir() #
['__builtins__', '__doc__', '__name__', '__package__', 'sys']
>>> a = 5 # 'a'
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'a', 'sys']
>>> del a # 'a'
>>> dir()
['__builtins__', '__doc__', '__name__', '__package__', 'sys']
>>>

:
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

A Byte of Python (Russian), 2.01


, world asia,
africa .., , , india, madagascar
..
:
| - < sys.path>/
| |---- world/
|
|---- __init__.py
|
|---- asia/
|
|
|---- __init__.py
|
|
|---- india/
|
|
|---- __init__.py
|
|
|---- foo.py
|
|---- africa/
|
|---- __init__.py
|
|---- madagascar/
|
|---- __init__.py
|
|---- bar.py

. .

11.7
, , . . Python .
, .
,
.

78

11.


, , ,
. , .
Python : , ,
. , , .

12.1
1 , , ..
. ,
, , , ,
,
Python .
, Python ,
. , ,
. , ,
, .. .

12.2
,
, .
.
.
i , , 5,
(.. ) i (.. ) int. ,
help(int).
, .. ,
. . , Python append list,
. mylist.append('and item')
1

list . (..)

79

A Byte of Python (Russian), 2.01


mylist. .
, , , . / , .
. , mylist.field.
: ( using_list.py)
#
shoplist = ['', '', '', '']
print(' ', len(shoplist), '.')
print(':', end=' ')
for item in shoplist:
print(item, end=' ')
print('\n .')
shoplist.append('')
print(' :', shoplist)
print('- ')
shoplist.sort()
print(' :', shoplist)
print(', , ', shoplist[0])
olditem = shoplist[0]
del shoplist[0]
print(' ', olditem)
print(' :', shoplist)

:
$ python3 using_list.py
4 .
:
.
: ['', '', '', '', '']
-
: ['', '', '', '',
'']
, ,

: ['', '', '', '']

:
80

12.

A Byte of Python (Russian), 2.01


shoplist , .
shoplist , , , .
for..in .
, , , .
.
end
print, ,
.
append
, . ,
,
print,
.
, sort .
, ,
. , . , , ,
.
. del. ,
, del . ,
, del shoplist[0] (,
Python 0).
, help(list).

12.3
.
, ,
. , , , . .. .
, ;
.
, , , .. , .
: ( using_tuple.py)
zoo = ('', '', '') # ,
print(' -', len(zoo))

12.3.

81

A Byte of Python (Russian), 2.01

new_zoo = '', '', zoo


print(' -', len(new_zoo))
print(' :', new_zoo)
print(', :', new_zoo[2])
print(' , -', new_zoo[2][2])
print(' -', len(new_zoo)-1+len(new_zoo[2]))

:
$ 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.

A Byte of Python (Russian), 2.01


( ) , Python
, . , , 2, singleton = (2,).
Perl
, .. ,
Perl. , ,
.. Python ,
.

12.4
, , ; .. ()
(). ,
, .
,
( ),
, . ,
.
- : d = {key1 : value1,
key2 : value2 }. , ,
, .
, - .
, .
/ dict.
: ( using_dict.py)
# 'ab' - 'a'ddress'b'ook
ab = {

'Swaroop'
'Larry'
'Matsumoto'
'Spammer'

:
:
:
:

'swaroop@swaroopch.com',
'larry@wall.org',
'matz@ruby-lang.org',
'spammer@hotmail.com'

}
print(" Swaroop':", ab['Swaroop'])
# -

12.4.

83

A Byte of Python (Russian), 2.01

del ab['Spammer']
print('\n {0} \n'.format(len(ab)))
for name, address in ab.items():
print(' {0} {1}'.format(name, address))
# -
ab['Guido'] = 'guido@python.org'
if 'Guido' in ab:
print("\n Guido:", ab['Guido'])

:
$ python3 using_dict.py
Swaroop': swaroop@swaroopch.com
3
Swaroop swaroop@swaroopch.com
Matsumoto matz@ruby-lang.org
Larry larry@wall.org
Guido: guido@python.org

:
ab2 , .
-, , . ,
.
-
del. , del.
,
.
- , items, ,
: . name address for..in,
for.
-
, Guido .
2

84

address book . (. .)

12.

A Byte of Python (Russian), 2.01


, -, in.
dict help(dict).

, , ! : -
, ,
, , (
).

12.5
, . ?
(.. in not in)
, .
, (, ),
, , .. .
: ( seq.py)
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

A Byte of Python (Russian), 2.01

print('
print('
print('
print('

1 3:', name[1:3])
2 :', name[2:])
1 -1:', name[1:-1])
:', name[:])

:
$ python3 seq.py
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.

A Byte of Python (Russian), 2.01


Python . ,
,
, ..
, .
, shoplist[1:3] ,
1, 2,
3, . ,
shoplist[:] .
. . ,
shoplist[:-1] , , .
, , ( 1):
>>> shoplist = ['', '', '', '']
>>> shoplist[::1]
['', '', '', '']
>>> shoplist[::2]
['', '']
>>> shoplist[::3]
['', '']
>>> shoplist[::-1]
['', '', '', '']

, 2, , 0, 2, 3,
0, 3, ..
, Python, .. , .
, , !

12.6
. , ,
.
, , , ,
.

12.6.

87

A Byte of Python (Russian), 2.01

>>> bri = set(['', '', ''])


>>> '' in bri
True
>>> '' in bri
False
>>> bric = bri.copy()
>>> bric.add('')
>>> bric.issuperset(bri)
True
>>> bri.remove('')
>>> bri & bric # OR bri.intersection(bric)
{'', ''}

:
, .

12.7
,
, !
, .
.
, , :
: ( reference.py)
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.

A Byte of Python (Russian), 2.01

:
$ python3 reference.py

shoplist: ['', '', '']
mylist: ['', '', '']

shoplist: ['', '', '']
mylist: ['', '']

:
.
, , ( ,
), . ,
, , .

12.8
. ? ,
, , ,
:
?
, , str. . , help(str).
: ( str_methods.py)
name = 'Swaroop' #
if name.startswith('Swa'):
print(', "Swa"')
if 'a' in name:
print(', "a"')
if name.find('war') != -1:
print(', "war"')
delimiter = '_*_'

12.8.

89

A Byte of Python (Russian), 2.01

mylist = ['', '', '', '']


print(delimiter.join(mylist))

:
$ 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

A Byte of Python (Russian), 2.01

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 + os.sep + time.strftime('%Y%m%d%H%M%S') + '.zip'
# 5. "zip" zip-
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
#
if os.system(zip_command) == 0:
print(' ', target)
else:
print(' ')

:
$ python3 backup_ver1.py
E:\\Backup\\20080702185040.zip

, , . , , ()1 , .. () .
, print(zip_command)
os.system . zip_command , ,
. ,
1

debug (
, bug, .. ). ,
, bug
, , 1878 .
(. .)

92

13.

A Byte of Python (Russian), 2.01


zip, , . , , Python ,
.
:
, .
os time, .
source2 .
, , target_dir. zip-,
, ,
time.strftime(). .zip, target_dir.
os.sep , .. '/'
GNU/Linux Unix3 , '\\' Windows ':' Mac OS. os.sep ,
.
time.strftime()
, , , . %Y . %m
01 12, . Python.
zip- , , .. .
zip_command, , . , , ( GNU/Linux
DOS).
zip, , .
-q , 4 . -r , 5
, .. .
-qr.
zip-,
. source , join.
2

source . (..)
Unix ,
Unix, .
GNU/Linux, *BSD, Android, Solaris .. (..)
4
quietly . (..)
5
recursive . (..)
3

13.2.

93

A Byte of Python (Russian), 2.01


, , os.system, , , ..
. 0, ,
.
,
, .
, !
Windows

6 . , C:\\Documents
r'C:\Documents'. , 'C:\Documents', , \D.
, , . GNU/Linux Unix , .
.
, , , ()
, . ,
..
.

13.3
. , ,
.
.
, , : ,
, , . ,
, .
, . , , ,
.
backup_ver2.py:
6

94

raw . , (.)

13.

A Byte of Python (Russian), 2.01

import os
import time
# 1. , , .
source = ['"C:\\My Documents"', 'C:\\Code']
# , , ,
# .
# 2. .
target_dir = 'E:\\Backup' # , .
# 3. zip-.
# 4.
today = target_dir + os.sep + time.strftime('%Y%m%d')
# zip-
now = time.strftime('%H%M%S')
# ,
if not os.path.exists(today):
os.mkdir(today) #
print(' ', today)
# zip-
target = today + os.sep + now + '.zip'
# 5. "zip" zip-
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
#
if os.system(zip_command) == 0:
print(' ', target)
else:
print(' ')

:
$ python3 backup_ver2.py
E:\\Backup\\20080702
E:\\Backup\\20080702\\202311.zip
$ python3 backup_ver2.py
E:\\Backup\\20080702\\202325.zip

:
. ,
, , ,
. 13.3.

95

A Byte of Python (Russian), 2.01


os.path.exists. ,
os.mkdir.

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 + os.sep + time.strftime('%Y%m%d')
# zip-
now = time.strftime('%H%M%S')
#
comment = input(' --> ')
if len(comment) == 0: # ,
target = today + os.sep + now + '.zip'
else:
target = today + os.sep + now + '_' +
comment.replace(' ', '_') + '.zip'
# ,
if not os.path.exists(today):
os.mkdir(today) #
print(' ', today)

96

13.

A Byte of Python (Russian), 2.01

# 5. "zip" zip-
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
#
if os.system(zip_command) == 0:
print(' ', target)
else:
print(' ')

:
$ python3 backup_ver3.py
File "backup_ver3.py", line 25
target = today + os.sep + 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

bug xing , (.)

13.5.

97

A Byte of Python (Russian), 2.01

# .
# 2. .
target_dir = 'E:\\Backup' # , .
# 3. zip-.
# 4.
today = target_dir + os.sep + time.strftime('%Y%m%d')
# zip-
now = time.strftime('%H%M%S')
#
comment = input(' --> ')
if len(comment) == 0: # ,
target = today + os.sep + now + '.zip'
else:
target = today + os.sep + now + '_' + \
comment.replace(' ', '_') + '.zip'
# ,
if not os.path.exists(today):
os.mkdir(today) #
print(' ', today)
# 5. "zip" zip-
zip_command = "zip -qr {0} {1}".format(target, ' '.join(source))
#
if os.system(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\202839.zip

:
! , 3.
input, , 98

13.

A Byte of Python (Russian), 2.01


, len.
ENTER, ( , ,
), , .
, zip-
.zip. , :
.

13.6

, . , 8 , -v
.
.
sys.argv source extend list.

os.system ,
zipfile tarfile. , zip .
os.system
,
, , - .
ziple
os.system.

13.7
.
:
()
()
8

verbosity . .
, .. .
(.)

13.6.

99

A Byte of Python (Russian), 2.01


()
( )
( )
()
,
: .
. . , , , . ,
, . , , .

13.8
, / Python,
.
, ,
Python, .
- .

100

13.

, .. , . - . :
. - .
, , - .
- . , . , int, , ,
, () int.

, ( int),
C++ Java ( 1.5), . .
help(int) . C# Java 1.5
1 .
, . , , .
, .. , . . ,
,
. ( ) .
: . .
class.
1

boxing and unboxing

101

A Byte of Python (Russian), 2.01


.

14.1 self
: , . , Python. , self2 .
,
self; . : -, , , ; -, (IDE) self.
C++, Java C#
self Python this C++ this Java C#.

, , , Python self
. . ,
MyClass myobject. , , myobject.method(arg1, arg2), Python MyClass.method(myobject, arg1, arg2)
self.
, - , self.

14.2
( simplestclass.py).
class Person:
pass #
p = Person()
print(p)

:
$ python3 simplestclass.py
<__main__.Person object at 0x019F85F0>

:
2

self . (..)

102

14. -

A Byte of Python (Russian), 2.01


class .
, .
, pass.
- , . ( ).
, . ,
Person __main__.
, ,
. ,
Python , .

14.3
, / ,
, self. ( method.py).
class Person:
def sayHi(self):
print('! ?')
p = Person()
p.sayHi()
# Person().sayHi()

:
$ python3 method.py
! ?

:
self . , sayHi
, , self .

14.4

__init__

, Python.
__init__.
__init__ , .
, . .
: ( class_init.py)
14.3.

103

A Byte of Python (Russian), 2.01

class Person:
def __init__(self, name):
self.name = name
def sayHi(self):
print('! ', self.name)
p = Person('Swaroop')
p.sayHi()
# Person('Swaroop').sayHi()

:
$ python3 class_init.py
! Swaroop

:
__init__ , name
( self). name. , , ,
name. , self.name
, name, self, name .
, , .
,
__init__ ,
. .
self.name
, sayHi.

14.5
(.. ) ,
. , .. , ,
, . ,
.
.
: , , .
. , ,
104

14. -

A Byte of Python (Russian), 2.01


.
.
, .. .
( objvar.py):
class Robot:
''' .'''
# ,
population = 0
def __init__(self, name):
''' .'''
self.name = name
print('( {0})'.format(self.name))
# ,
# 'population'
Robot.population += 1
def __del__(self):
''' .'''
print('{0} !'.format(self.name))
Robot.population -= 1
if Robot.population == 0:
print('{0} .'.format(self.name))
else:
print(' {0:d} .'.format(Robot.population))
def sayHi(self):
''' .
, .'''
print('! {0}.'.format(self.name))
def howMany():
''' .'''
print(' {0:d} .'.format(Robot.population))
howMany = staticmethod(howMany)
droid1 = Robot('R2-D2')
droid1.sayHi()
Robot.howMany()

14.5.

105

A Byte of Python (Russian), 2.01

droid2 = Robot('C-3PO')
droid2.sayHi()
Robot.howMany()
print("\n - .\n")
print(" . .")
del droid1
del droid2
Robot.howMany()

:
$ python3 objvar.py
( R2-D2)
! R2-D2.
1 .
( C-3PO)
! C-3PO.
2 .
- .
. .
R2-D2 !
1 .
C-3PO !
C-3PO .
0 .

:
, . population Robot, . name (
self),
.
, population
Robot.population, self.population. name

self.name.
. , ,
, () !
howMany , . , classmethod staticmethod, ,
, .
106

14. -

A Byte of Python (Russian), 2.01


, staticmethod.
, :
@staticmethod
def howMany():
''' .'''
print(' {0:d} .'.format(Robot.population))

,
.
, __init__ Robot
. population 1,
. , self.name ,
.
, ,
self. .
, . Robot.__doc__,
Robot.sayHi.__doc__.
__init__, __del__,
, , .. ,
. Robot.population 1.
__del__ , ,
, .
, del, .
C++/Java/C#
Python ( ) (public),
(virtual).
: , , ,
__privatevar, Python (private).
, ,
; , /. , , Python
( ).

14.5.

107

A Byte of Python (Russian), 2.01

14.6
- ,
. .
, ,
. :
, . , ,
, .
,
-
, .
SchoolMember, ,
, ..
(), .
. / -
SchoolMember, .
, , SchoolMember. ,
. , SchoolMember,
, , . , , ..
, .
, , , .
SchoolMember 3 .
Teacher Student 4 .
( inherit.py).
class SchoolMember:
''' .'''
def __init__(self, name, age):
self.name = name
self.age = age
print('( SchoolMember: {0})'.format(self.name))
def tell(self):
3
4

, (..)
, - (..)

108

14. -

A Byte of Python (Russian), 2.01

''' .'''
print(':"{0}" :"{1}"'.format(self.name, self.age), end=" ")
class Teacher(SchoolMember):
''' .'''
def __init__(self, name, age, salary):
SchoolMember.__init__(self, name, age)
self.salary = salary
print('( Teacher: {0})'.format(self.name))
def tell(self):
SchoolMember.tell(self)
print(': "{0:d}"'.format(self.salary))
class Student(SchoolMember):
''' .'''
def __init__(self, name, age, marks):
SchoolMember.__init__(self, name, age)
self.marks = marks
print('( Student: {0})'.format(self.name))
def tell(self):
SchoolMember.tell(self)
print(': "{0:d}"'.format(self.marks))
t = Teacher('Mrs. Shrividya', 40, 30000)
s = Student('Swaroop', 25, 75)
print() #
members = [t, s]
for member in members:
member.tell() # ,

:
$ python3 inherit.py
( SchoolMember: Mrs. Shrividya)
( Teacher: Mrs. Shrividya)
( SchoolMember: Swaroop)
( Student: Swaroop)
:"Mrs. Shrividya" :"40" : "30000"
:"Swaroop" :"25" : "75"

:
, 14.6.

109

A Byte of Python (Russian), 2.01


,
. , __init__ self, ,
. : Python
.
, ,
, self .
, tell SchoolMember
Teacher Student
SchoolMember.
, tell , tell
SchoolMember. : Python , .
, , , ,
.
: , .
end tell() , print().

14.7

- , ,
.
, , .
.
. , ,
SchoolMember,
SchoolMember.
. , , ..
, .
5

, It is too sudden to introduce this concept here.,


. (..)

110

14. -

A Byte of Python (Russian), 2.01



ABCMeta.
#!/usr/bin/env python
# Filename: inherit_abc.py
from abc import *
class SchoolMember(metaclass=ABCMeta):
''' .'''
def __init__(self, name, age):
self.name = name
self.age = age
print('( SchoolMember: {0})'.format(self.name))
@abstractmethod
def tell(self):
''' .'''
print(':"{0}" :"{1}"'.format(self.name, self.age), end=" ")
class Teacher(SchoolMember):
''' .'''
def __init__(self, name, age, salary):
SchoolMember.__init__(self, name, age)
self.salary = salary
print('( Teacher: {0})'.format(self.name))
def tell(self):
SchoolMember.tell(self)
print(': "{0:d}"'.format(self.salary))
class Student(SchoolMember):
''' .'''
def __init__(self, name, age, marks):
SchoolMember.__init__(self, name, age)
self.marks = marks
print('( Student: {0})'.format(self.name))
def tell(self):
SchoolMember.tell(self)
print(': "{0:d}"'.format(self.marks))
t = Teacher('Mrs. Shrividya', 40, 30000)
s = Student('Swaroop', 25, 75)
#m = SchoolMember('abc', 10)
# : "TypeError: Can't instantiate abstract class
# SchoolMember with abstract methods tell"

14.7.

111

A Byte of Python (Russian), 2.01

print() #
members = [t, s]
for member in members:
member.tell() # ,

:
$ python3 inherit.py
( 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

A Byte of Python (Russian), 2.01

$ 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. -

A Byte of Python (Russian), 2.01


: ( using_file.py)
poem = '''\
.
,
Python!
'''
f = open('poem.txt', 'w') # (writing)
f.write(poem) #
f.close() #
f = open('poem.txt') # ,
# ('r'eading)
while True:
line = f.readline()
if len(line) == 0: # (EOF)
break
print(line, end='')
f.close() #

:
$ python3 using_file.py
.
,
Python!

:
open , .
('r'), ('w') ('a')2 . , , :
('t') ('b'). , help(open) .
open() .
write , close.
.
,
. readline .
2

read, write append (..)

15.2.

115

A Byte of Python (Russian), 2.01


, .
, ,
, break.
print() , . , end='',
, ,
. , , close.
poem.txt, , .

15.3 Pickle
Python pickle3 , Python , .
.
: ( pickling.py):
import pickle
# ,
shoplistfile = 'shoplist.data'
#
shoplist = ['', '', '']
#
f = open(shoplistfile, 'wb')
pickle.dump(shoplist, f) #
f.close()
del shoplist # shoplist
#
f = open(shoplistfile, 'rb')
storedlist = pickle.load(f) #
print(storedlist)

:
$ python3 pickling.py
['', '', '']

:
3

pickle . , (..)

116

15. -

A Byte of Python (Russian), 2.01


,
open ('wb'), dump
pickle. (pickling).
load
pickle, . (unpickling).

15.4
/,
pickle.
.

15.4.

117

A Byte of Python (Russian), 2.01

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

A Byte of Python (Russian), 2.01

s = input(' - --> ')


EOFError: EOF when reading a line

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.

A Byte of Python (Russian), 2.01


, try
except. try?
, Python ,
. .
else try..except.
, .
, .

16.4
raise2 , /, , .
,
Exception.
: ( raising.py)
class ShortInputException(Exception):
''' .'''
def __init__(self, length, atleast):
Exception.__init__(self)
self.length = length
self.atleast = 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(ex.length, ex.atleast))
else:
print(' .')

:
$ python3 raising.py
- -->
2

raise . (..)

16.4.

121

A Byte of Python (Russian), 2.01

ShortInputException: -- 1; , , 3
$ python3 raising.py
- -->
.

:
. ShortInputException. : length, , atleast, ,
.
except ShortInputException, 3 ex,
/.
. except length atleast
.

16.5 Try .. Finally


, , .
finally.
finally.py:
import time
try:
f = open('poem.txt')
while True: #
line = f.readline()
if len(line) == 0:
break
print(line, end='')
time.sleep(2) #
except KeyboardInterrupt:
print('!! .')
finally:
f.close()
print('(: )')

:
3

as . (..)

122

16.

A Byte of Python (Russian), 2.01

$ python3 finally.py

,
!! .
(: )

:
,
time.sleep, ( Python
). ctrl-c,
/ .
, KeyboardInterrupt,
. , ,
finally, .

16.6 with
try finally. , ,
with4 :
using_with.py:
with open("poem.txt") 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

A Byte of Python (Russian), 2.01


,
. PEP 343.

16.7
try..except try..finally. , .
Python.

124

16.


Python Python.
Python , ,
.
. Python
Library Reference , Python.
.

, . , Python.

17.1 sys
sys , . ,
sys.argv .
, Python , ,
, , 3. sys .
>>> import sys
>>> sys.version_info
(3, 0, 0, 'beta', 2)
>>> sys.version_info[0] >= 3
True

:
sys version_info,
. . -

125

A Byte of Python (Russian), 2.01


, , , ,
Python 3.0:
versioncheck.py:
import sys, warnings
if sys.version_info[0] < 3:
warnings.warn(" \
Python 3.0",
RuntimeWarning)
else:
print(' ')

:
$ python2.7 versioncheck.py
versioncheck.py:6:
Python 3.0
RuntimeWarning)
$ python3 versioncheck.py

:
, warnings . Python 3, .

17.2 logging
,
-, ,
, . - ?
logging.
use_logging.py:
import os, platform, logging
if platform.platform().startswith('Windows'):
logging_file = os.path.join(os.getenv('HOMEDRIVE'), \
os.getenv('HOMEPATH'), \
'test.log')
else:
logging_file = os.path.join(os.getenv('HOME'), 'test.log')
print(" ", logging_file)

126

17.

A Byte of Python (Russian), 2.01

logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s : %(levelname)s : %(message)s',
filename = logging_file,
filemode = 'w',
)
logging.debug(" ")
logging.info("- ")
logging.warning(" ")

:
$ python3 use_logging.py
C:\Users\swaroop\test.log

test.log, :
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 .

,
platform.platform() , ( . import platform;
help(platform)). Windows, ,
, , . ,
.
, .
os.path.join() .
, , ,
.
logging , .
, , , , . , 1

log . , (..)

17.2. logging

127

A Byte of Python (Russian), 2.01


, , ,
.

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

A Byte of Python (Russian), 2.01

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.

A Byte of Python (Russian), 2.01

18.4 Lambda-
lambda
. lambda ,
, , .
: ( lambda.py)
points = [ { 'x' : 2, 'y' : 3 }, { 'x' : 4, 'y' : 1 } ]
points.sort(key=lambda i : i['y'])
print(points)

:
$ python3 lambda.py
[{'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

A Byte of Python (Russian), 2.01


, , (2 * i), (if i > 2).
, .
, ,
.

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 . **
/ .

18.7 exec eval


exec Python, , . ,
, Python,
exec:
>>> exec('print(", !")')
, !

, eval Python, . .

132

18.

A Byte of Python (Russian), 2.01

>>> eval('2*3')
6

18.8 assert
assert , , . , , ,
, , assert .
, AssertionError.
>>> mylist = ['item']
>>> assert len(mylist)
>>> mylist.pop()
'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 = []
>>> i.append('item')
>>> repr(i)
"['item']"
>>> eval(repr(i))
['item']
>>> eval(repr(i)) == i
True

, repr
. __repr__ , ,
repr.

18.8. assert

133

A Byte of Python (Russian), 2.01

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.

A Byte of Python (Russian), 2.01

18.12
,
Python, -, . ,
, - .
.
, Python.

18.12.

135

A Byte of Python (Russian), 2.01

136

18.


, , , Python. , - Python, . ? ! : ?.
.

, , , ,
. , .
, ,
. - , , .
( !)
. , . pickle. ,
.
, Python.
;-). , . ,
.
, :

replace. .

137

A Byte of Python (Russian), 2.01


replace :
( ).
Python:

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.

A Byte of Python (Russian), 2.01

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://kivy.org

19.5.

139

A Byte of Python (Russian), 2.01


PyGTK
Python GTK+,
GNOME. GTK+ , ,
. Glade, .
. GTK+ GNU/Linux, Windows
. GTK+ ,
. PyGTK.
PyQt
Python Qt, KDE. Qt
, Qt Designer Qt. PyQt ,
( GPL).
. Qt 4.5,
GPL . PyQt
PyQt.
wxPython
Python wxWidgets. wxPython , GNU/Linux, Windows, Mac . wxPython, SPE (Stanis
Python Editor) wxGlade . wxPython , .
wxPython.

19.11
wiki- GuiProgramming
Python.
,
Python. ,
, . -, , . -, , : Windows,
Mac GNU/Linux . -, GNU/Linux,
: KDE GNOME.
. 26 Python, 3, 1.

140

19.

A Byte of Python (Russian), 2.01

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

Classical Python interpreter (..)

19.12.

141

A Byte of Python (Russian), 2.01


Dive Into Python
Python

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

A Byte of Python (Russian), 2.01


.
[LibreOce]
Mozilla Firefox. - , Internet Explorer. ,
. . [Mozilla Firefox]
underbird ,
. [Mozilla underbird]
Mono. Microso .NET. .NET- GNU/Linux, Windows, FreeBSD, Mac OS . [Mono], [ECMA], [.NET]
Apae web server. -. , - . . ,
Apache , -
( Microso IIS) . [Apache]
MySQL. .
. M LAMP, . [MySQL]
VLC Player. , ,
DivX MP3, Ogg, VCD, DVD, , ? ;-)
[VLC media player]
GeexBox GNU/Linux,
CD! [GeexBox]
, ,
,
Perl, PHP, - Drupal,
PostgreSQL, TORCS, KDevelop, Xine, VIM, anta+, - Banshee, GIMP,
.
, :
linux.com
LinuxToday
NewsForge
DistroWatch
:
SourceForge
FreshMeat
, !

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

A Byte of Python (Russian), 2.01

21.1.3
Vim, Pandoc, Mac OS X.

21.2
hp://www.swaroopch.com/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

A Byte of Python (Russian), 2.01


, .

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. :

A Byte of Python (Russian), 2.01


0.90 (18/12/2003)
2 . OpenOce .

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

A Byte of Python (Russian), 2.01

150

22. :

hps://github.com/swaroopch/byte_of_python .

Git-

.
. Git.
.pd . Pandoc README,

README , PDF ..

151