abstract base classes, 4, 19
8 | animation, 40, 42-43
9 | argparse module, 22
10 | arguments, 10, 12, 22
11 | arrays, 29, 37-38
12 | asyncio module, 33
13 | audio, 40-41, 42
beautifulsoup library, 35
16 | binary representation, 7, 8
17 | bitwise operators, 8, 30
18 | bytes, 22-23, 25, 28-29
cache, 13
21 | callable, 17
22 | class, 4, 14-20
23 | closure, 12-13
24 | collection, 4, 18, 19
25 | collections module, 2, 3, 4, 19, 29
26 | combinatorics, 8
27 | command line arguments, 22
28 | comprehensions, 1, 2, 11
29 | context manager, 17, 23, 27, 32
30 | copy function, 15
31 | coroutine, 33
32 | counter, 2, 4, 12, 17
33 | csv, 26, 34, 46, 47
34 | curses module, 33, 34
35 | cython, 15, 49
dataclasses module, 11, 15
38 | datetime module, 8-9
39 | decorator, 13, 14, 15, 16
40 | deques, 29
41 | dictionaries, 2, 4, 10-11, 19, 21
42 | duck types, 16-19
enum module, 19-20
45 | enumerate function, 3
46 | excel, 46
47 | exceptions, 20-21, 23, 31
48 | exit function, 21
files, 22-29, 34, 46
51 | filter function, 11
52 | flask library, 36
53 | floats, 4, 6, 7
54 | format, 6-7
55 | functools module, 11, 12, 13, 16
games, 33, 42-43
58 | generators, 4, 11, 17
59 | global keyword, 10, 12
60 | gui app, 35
hashable, 15, 16
63 | hexadecimal representation, 7, 8, 28
image, 35, 39-40, 42-43
66 | imports, 12
67 | inline, 11, 15, 20
68 | input function, 22
69 | introspection, 21, 31
70 | ints, 4, 7-8, 28
71 | is operator, 16, 30
72 | iterable, 4, 18, 19
73 | iterator, 3-4, 11, 17
74 | itertools module, 3, 8
lambda, 11
79 | lists, 1-2, 4, 10-11, 18-19, 21
80 | locale module, 16
81 | logging, 31
main function, 1, 49
84 | match statement, 30
85 | matplotlib library, 34, 44, 45
86 | map function, 11, 30
87 | math module, 7
88 | memoryviews, 29
89 | module, 12
namedtuples, 3, 6
92 | nonlocal keyword, 12
93 | numbers, 4, 6-8
94 | numpy library, 37-38, 39, 44
open function, 17, 22-23, 25, 26, 28
97 | operator module, 30
98 | os commands, 23-25, 34
pandas library, 44-48
101 | partial function, 12, 20
102 | paths, 23-24, 34
103 | pickle module, 25
104 | pillow library, 39-40
105 | plotting, 34, 44, 45, 47-48
106 | print function, 14, 22
107 | profiling, 36-37
108 | progress bar, 34
109 | property decorator, 15, 16
110 | pygame library, 42-43
random module, 8, 33, 41
115 | ranges, 3, 4
116 | recursion, 13, 21
117 | reduce function, 11
118 | regular expressions, 5-6
119 | requests library, 35, 36
scope, 10, 12, 20
122 | scraping, 35, 43, 46, 47-48
123 | sequence, 4, 18-19
124 | sets, 2, 4, 10-11, 19, 21
125 | shell commands, 25
126 | sleep function, 34
127 | sortable, 1, 16
128 | splat operator, 10, 26
129 | sql, 27, 46
130 | statistics, 7, 37-38, 44-48
131 | strings, 4-7, 14
132 | struct module, 28-29
133 | subprocess module, 25
134 | super function, 14
135 | sys module, 13, 21-22
table, 26, 27, 34, 37-38, 45-46
138 | template, 6, 36
139 | threading module, 32, 36
140 | time module, 34, 36
141 | tuples, 3, 4, 10-11, 18-19
142 | type, 4, 16, 30
143 | type annotations, 15, 31
abstract base classes, 4, 19
8 | animation, 40, 42-43
9 | argparse module, 22
10 | arguments, 10, 12, 22
11 | arrays, 29, 37-38
12 | asyncio module, 33
13 | audio, 40-41, 42
beautifulsoup library, 35
16 | binary representation, 7, 8
17 | bitwise operators, 8, 30
18 | bytes, 22-23, 25, 28-29
cache, 13
21 | callable, 17
22 | class, 4, 14-20
23 | closure, 12-13
24 | collection, 4, 18, 19
25 | collections module, 2, 3, 4, 19, 29
26 | combinatorics, 8
27 | command line arguments, 22
28 | comprehensions, 1, 2, 11
29 | context manager, 17, 23, 27, 32
30 | copy function, 15
31 | coroutine, 33
32 | counter, 2, 4, 12, 17
33 | csv, 26, 34, 46, 47
34 | curses module, 33, 34
35 | cython, 15, 49
dataclasses module, 11, 15
38 | datetime module, 8-9
39 | decorator, 13, 14, 15, 16
40 | deques, 29
41 | dictionaries, 2, 4, 10-11, 19, 21
42 | duck types, 16-19
enum module, 19-20
45 | enumerate function, 3
46 | excel, 46
47 | exceptions, 20-21, 23, 31
48 | exit function, 21
files, 22-29, 34, 46
51 | filter function, 11
52 | flask library, 36
53 | floats, 4, 6, 7
54 | format, 6-7
55 | functools module, 11, 12, 13, 16
games, 33, 42-43
58 | generators, 4, 11, 17
59 | global keyword, 10, 12
60 | gui, 35
hashable, 15, 16
63 | hexadecimal representation, 7, 8, 28
image, 35, 39-40, 42-43
66 | imports, 12
67 | inline, 11, 15, 20
68 | input function, 22
69 | introspection, 21, 31
70 | ints, 4, 7-8, 28
71 | is operator, 16, 30
72 | iterable, 4, 18, 19
73 | iterator, 3-4, 11, 17
74 | itertools module, 3, 8
json, 25, 36, 46
77 |lambda, 11
79 | lists, 1-2, 4, 10-11, 18-19, 21
80 | locale module, 16
81 | logging, 31
main function, 1, 49
84 | match statement, 30
85 | matplotlib library, 34, 44, 45
86 | map function, 11, 30
87 | math module, 7
88 | memoryviews, 29
89 | module, 12
namedtuples, 3, 6
92 | nonlocal keyword, 12
93 | numbers, 4, 6-8
94 | numpy library, 37-38, 39, 44
open function, 17, 22-23, 25, 26, 28
97 | operator module, 30
98 | os commands, 23-25, 34
pandas library, 44-48
101 | partial function, 12, 20
102 | paths, 23-24, 34
103 | pickle module, 25
104 | pillow library, 39-40
105 | plotting, 34, 44, 45, 47-48
106 | print function, 14, 22
107 | profiling, 36-37
108 | progress bar, 34
109 | property decorator, 15, 16
110 | pygame library, 42-43
queues, 29, 32, 33
113 |random module, 8, 33, 41
115 | ranges, 3, 4
116 | recursion, 13, 21
117 | reduce function, 11
118 | regular expressions, 5-6
119 | requests library, 35, 36
scope, 10, 12, 20
122 | scraping, 35, 43, 46, 47-48
123 | sequence, 4, 18-19
124 | sets, 2, 4, 10-11, 19, 21
125 | shell commands, 25
126 | sleep function, 34
127 | sortable, 1, 16
128 | splat operator, 10, 26
129 | sql, 27, 46
130 | statistics, 7, 37-38, 44-48
131 | strings, 4-7, 14
132 | struct module, 28-29
133 | subprocess module, 25
134 | super function, 14
135 | sys module, 13, 21-22
table, 26, 27, 34, 37-38, 45-46
138 | template, 6, 36
139 | threading module, 32, 36
140 | time module, 34, 36
141 | tuples, 3, 4, 10-11, 18-19
142 | type, 4, 16, 30
143 | type annotations, 15, 31
wave module, 40-41
146 | web, 36
4 |
5 | 6 |\'!r\'
to the expression converts object to string by calling its repr() method.': 'Adding \'!r\'
to the expression converts object to string by calling its repr() method.',
14 | 'It can be any callable, but is usually implemented as a function that returns a closure.': 'It can be any callable, but is usually implemented as a function that returns a closure.',
15 | 'Hints are used by type checkers like mypy, data validation libraries such as Pydantic and lately also by Cython compiler. However, they are not enforced by CPython interpreter.': 'Hints are used by type checkers like mypy, data validation libraries such as Pydantic and lately also by Cython compiler. However, they are not enforced by CPython interpreter.',
16 | 'Objects can be made sortable with \'order=True\'
and immutable with \'frozen=True\'
.': 'Objects can be made sortable with \'order=True\'
and immutable with \'frozen=True\'
.',
17 | 'For object to be hashable, all attributes must be hashable and \'frozen\' must be True.': 'For object to be hashable, all attributes must be hashable and \'frozen\' must be True.',
18 | 'Function field() is needed because \'<attr_name>: list = []\'
would make a list that is shared among all instances. Its \'default_factory\' argument can be any callable.': 'Function field() is needed because \'<attr_name>: list = []\'
would make a list that is shared among all instances. Its \'default_factory\' argument can be any callable (p. 17).',
19 | 'Sequence iterators returned by the iter() function, such as list_iterator and set_iterator.': 'Sequence iterators returned by the iter() function, such as list_iterator and set_iterator.',
20 | 'Objects returned by the itertools module, such as count, repeat and cycle.': 'Objects returned by the itertools module, such as count, repeat and cycle (p. 3).',
21 | 'Generators returned by the generator functions and generator expressions.': 'Generators returned by the generator functions (p. 4) and generator expressions (p. 11).',
22 | 'File objects returned by the open() function, etc.': 'File objects returned by the open() function (p. 22), etc.',
23 | 'Use \'logging.exception(<str>)\'
to log the passed message, followed by the full error message of the caught exception. For details see Logging.': 'Use \'logging.exception(<str>)\'
to log the passed message, followed by the full error message of the caught exception. For details see Logging (p. 31).',
24 | 'Functions report OS related errors by raising OSError or one of its subclasses.': 'Functions report OS related errors by raising OSError or one of its subclasses (p. 23).',
25 | 'To print the spreadsheet to the console use Tabulate library.': 'To print the spreadsheet to the console use Tabulate library (p. 34).',
26 | 'For XML and binary Excel files (xlsx, xlsm and xlsb) use Pandas library.': 'For XML and binary Excel files (xlsx, xlsm and xlsb) use Pandas library (p. 46).',
27 | 'Bools will be stored and returned as ints and dates as ISO formatted strings.': 'Bools will be stored and returned as ints and dates as ISO formatted strings (p. 9).',
28 | 'ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be pickable, queues must be sent using executor\'s \'initargs\' and \'initializer\' parameters, and executor should only be reachable via \'if __name__ == "__main__": ...\'
.': 'ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be pickable, queues must be sent using executor\'s \'initargs\' and \'initializer\' parameters, and executor should only be reachable via \'if __name__ == "__main__": ...\'
.',
29 | 'Install a WSGI server like Waitress and a HTTP server such as Nginx for better security.': 'Install a WSGI server like Waitress and a HTTP server such as Nginx for better security.',
30 | 'Data analysis library. For examples see Plotly.': 'Data analysis library. For examples see Plotly (p. 47).',
31 | }
32 |
33 |
34 | def main():
35 | index_path = Path('..', 'index.html')
36 | lines = read_file(index_path)
37 | out = ''.join(lines)
38 | for from_, to_ in MATCHES.items():
39 | out = out.replace(from_, to_, 1)
40 | write_to_file(index_path, out)
41 |
42 |
43 | ###
44 | ## UTIL
45 | #
46 |
47 | def read_file(filename):
48 | p = Path(__file__).resolve().parent / filename
49 | with open(p, encoding='utf-8') as file:
50 | return file.readlines()
51 |
52 |
53 | def write_to_file(filename, text):
54 | p = Path(__file__).resolve().parent / filename
55 | with open(p, 'w', encoding='utf-8') as file:
56 | file.write(text)
57 |
58 |
59 | if __name__ == '__main__':
60 | main()
61 |
--------------------------------------------------------------------------------
/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.eot
--------------------------------------------------------------------------------
/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.ttf
--------------------------------------------------------------------------------
/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.woff
--------------------------------------------------------------------------------
/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gto76/python-cheatsheet/fed9b8f90b3ffe19c6f6163f596e65c91cf5dc58/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/9f94dc20bb2a09c15241d3a880b7ad01.woff2
--------------------------------------------------------------------------------
/web/OnlineWebFonts_COM_cb7eb796ae7de7195a34c485cacebad1/@font-face/Demo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 1Use font-face declaration Fonts.
27 |
28 |
29 | @font-face {font-family: "Menlo Regular";
30 | src: url("9f94dc20bb2a09c15241d3a880b7ad01.eot"); /* IE9*/
31 | src: url("9f94dc20bb2a09c15241d3a880b7ad01.eot?#iefix") format("embedded-opentype"), /* IE6-IE8 */
32 | url("9f94dc20bb2a09c15241d3a880b7ad01.woff2") format("woff2"), /* chrome、firefox */
33 | url("9f94dc20bb2a09c15241d3a880b7ad01.woff") format("woff"), /* chrome、firefox */
34 | url("9f94dc20bb2a09c15241d3a880b7ad01.ttf") format("truetype"), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
35 | url("9f94dc20bb2a09c15241d3a880b7ad01.svg#Menlo Regular") format("svg"); /* iOS 4.1- */
36 | }
37 |
38 |
39 |
2Settings font css style
42 |
43 |
44 | .demo{
45 | font-family:"Menlo Regular" !important;
46 | font-size:16px;font-style:normal;
47 | -webkit-font-smoothing: antialiased;
48 | -webkit-text-stroke-width: 0.2px;
49 | -moz-osx-font-smoothing: grayscale;}
50 |
51 |
52 |
3View DEMO
55 |
56 | <div class="demo"> www.OnlineWebFonts.Com </div>
57 |
58 |
OROr add to the head section of page.
61 |
62 | <link href="//db.onlinewebfonts.com/c/9f94dc20bb2a09c15241d3a880b7ad01?family=Menlo+Regular" rel="stylesheet" type="text/css"/>
63 |
64 |
69 | 70 | OnlineWebFonts.Com features an amazing collection of free fonts, 71 | premium fonts and free dingbats. With over 8,000,000 freeware fonts, 72 | you've come to the best place to download fonts! 73 | 74 | OnlineWebFonts.Com Some fonts provided are trial versions of full versions and may not allow embedding 75 | unless a commercial license is purchased or may contain a limited character set. 76 | Please review any files included with your download, 77 | which will usually include information on the usage and licenses of the fonts. 78 | If no information is provided, 79 | please use at your own discretion or contact the author directly. 80 | 81 | 0123456789 /*-+~!@#$%^&*()-=_+{}[]:;"'|\<>.? 82 | 83 |84 |
1Use font-face declaration Fonts.
27 |
28 |
29 | @font-face {font-family: "Menlo Bold";
30 | src: url("a6ffc5d72a96b65159e710ea6d258ba4.eot"); /* IE9*/
31 | src: url("a6ffc5d72a96b65159e710ea6d258ba4.eot?#iefix") format("embedded-opentype"), /* IE6-IE8 */
32 | url("a6ffc5d72a96b65159e710ea6d258ba4.woff2") format("woff2"), /* chrome、firefox */
33 | url("a6ffc5d72a96b65159e710ea6d258ba4.woff") format("woff"), /* chrome、firefox */
34 | url("a6ffc5d72a96b65159e710ea6d258ba4.ttf") format("truetype"), /* chrome、firefox、opera、Safari, Android, iOS 4.2+*/
35 | url("a6ffc5d72a96b65159e710ea6d258ba4.svg#Menlo Bold") format("svg"); /* iOS 4.1- */
36 | }
37 |
38 |
39 |
2Settings font css style
42 |
43 |
44 | .demo{
45 | font-family:"Menlo Bold" !important;
46 | font-size:16px;font-style:normal;
47 | -webkit-font-smoothing: antialiased;
48 | -webkit-text-stroke-width: 0.2px;
49 | -moz-osx-font-smoothing: grayscale;}
50 |
51 |
52 |
3View DEMO
55 |
56 | <div class="demo"> www.OnlineWebFonts.Com </div>
57 |
58 |
OROr add to the head section of page.
61 |
62 | <link href="//db.onlinewebfonts.com/c/a6ffc5d72a96b65159e710ea6d258ba4?family=Menlo+Bold" rel="stylesheet" type="text/css"/>
63 |
64 |
69 | 70 | OnlineWebFonts.Com features an amazing collection of free fonts, 71 | premium fonts and free dingbats. With over 8,000,000 freeware fonts, 72 | you\'ve come to the best place to download fonts! 73 | 74 | OnlineWebFonts.Com Some fonts provided are trial versions of full versions and may not allow embedding 75 | unless a commercial license is purchased or may contain a limited character set. 76 | Please review any files included with your download, 77 | which will usually include information on the usage and licenses of the fonts. 78 | If no information is provided, 79 | please use at your own discretion or contact the author directly. 80 | 81 | 0123456789 /*-+~!@#$%^&*()-=_+{}[]:;"\'|\<>.? 82 | 83 |84 |
Ctrl+F
/ ⌘F
. If you're on the webpage, searching for '#<name>'
will only search for the titles. To get a link to a specific section click the grey hashtag next to the section's title before copying the address. To search for titles in the text editor use ^<name>
with enabled regular expressions option.help(<module/object/function/type/str>)
command. If something is still unclear, then I search the Python docs by googling 'python docs <module/function>'
.pip3 install ptpython
. Even more recently I switched to ipython REPL, which is very similar to ptpython only more responsive. It can be installed with pip3 install ipython
.
10 | =
) then it signifies what type of object is produced/returned by the expression on the right side of the assignment.
14 | <el>
?<collection>
?<object>.__iter__()
should return an iterator of object's items and <object>.__getitem__(<index>)
an item at that index. I chose not to use the name iterable because it sounds scarier and more vague than collection, even though it has a precise definition.instanceof(<object>, collections.abc.Iterable)
only checks whether an object has iter() special method, disregarding the getitem().instanceof(<object>, collections.abc.Collection)
returns 'True' for any object that has len(), iter() and contains() special methods defined. <object>.__len__()
should return the number of elements and <object>.__contains__(<el>)
should check if object contains the passed element.
28 | Ctrl+Alt+L
/ ⌥⌘L
shortcut in PyCharm to automatically reformat code.
32 |