From 313bfee5b40a8855092a18c12d9607bcb8696b57 Mon Sep 17 00:00:00 2001 From: lucastucker-umd <85323213+lucastucker-umd@users.noreply.github.com> Date: Wed, 8 Dec 2021 18:33:39 -0500 Subject: [PATCH 1/4] Test update --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f7d312aed..6d156e15e 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Contents **   ** **7. Libraries:** **      ** **[`Progress_Bar`](#progress-bar)**__,__ **[`Plot`](#plot)**__,__ **[`Table`](#table)**__,__ **[`Curses`](#curses)**__,__ **[`Logging`](#logging)**__,__ **[`Scraping`](#scraping)**__,__ **[`Web`](#web)**__,__ **[`Profile`](#profiling)**__,__ **                                 ** **[`NumPy`](#numpy)**__,__ **[`Image`](#image)**__,__ **[`Audio`](#audio)**__,__ **[`Games`](#pygame)**__,__ **[`Data`](#pandas)**__.__ +**[`List`](#list)** Main ---- From 18acd0b7bd1e5113b053916e4582b99a09c69513 Mon Sep 17 00:00:00 2001 From: lucastucker-umd <85323213+lucastucker-umd@users.noreply.github.com> Date: Wed, 8 Dec 2021 18:34:20 -0500 Subject: [PATCH 2/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6d156e15e..c536b58db 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Contents **   ** **7. Libraries:** **      ** **[`Progress_Bar`](#progress-bar)**__,__ **[`Plot`](#plot)**__,__ **[`Table`](#table)**__,__ **[`Curses`](#curses)**__,__ **[`Logging`](#logging)**__,__ **[`Scraping`](#scraping)**__,__ **[`Web`](#web)**__,__ **[`Profile`](#profiling)**__,__ **                                 ** **[`NumPy`](#numpy)**__,__ **[`Image`](#image)**__,__ **[`Audio`](#audio)**__,__ **[`Games`](#pygame)**__,__ **[`Data`](#pandas)**__.__ -**[`List`](#list)** +**[`Back To Contents`](#Contents)** Main ---- From 6f21bbcfcddebd9a0e6b9424afccc8a0d702bc92 Mon Sep 17 00:00:00 2001 From: lucastucker-umd <85323213+lucastucker-umd@users.noreply.github.com> Date: Wed, 8 Dec 2021 18:43:03 -0500 Subject: [PATCH 3/4] Button made for sections through class --- README.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c536b58db..d607e035e 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,6 @@ Contents **   ** **7. Libraries:** **      ** **[`Progress_Bar`](#progress-bar)**__,__ **[`Plot`](#plot)**__,__ **[`Table`](#table)**__,__ **[`Curses`](#curses)**__,__ **[`Logging`](#logging)**__,__ **[`Scraping`](#scraping)**__,__ **[`Web`](#web)**__,__ **[`Profile`](#profiling)**__,__ **                                 ** **[`NumPy`](#numpy)**__,__ **[`Image`](#image)**__,__ **[`Audio`](#audio)**__,__ **[`Games`](#pygame)**__,__ **[`Data`](#pandas)**__.__ -**[`Back To Contents`](#Contents)** - Main ---- ```python @@ -26,6 +24,7 @@ if __name__ == '__main__': # Runs main() if file wasn't imported. main() ``` +**[`Back To Contents`](#Contents)** List ---- @@ -66,6 +65,7 @@ list_of_chars = list() .clear() # Removes all items. Also works on dictionary and set. ``` +**[`Back To Contents`](#Contents)** Dictionary ---------- @@ -106,6 +106,7 @@ Counter({'blue': 3, 'red': 2, 'yellow': 1}) ('blue', 3) ``` +**[`Back To Contents`](#Contents)** Set --- @@ -140,6 +141,7 @@ Set = frozenset() ``` +**[`Back To Contents`](#Contents)** Tuple ----- @@ -168,6 +170,7 @@ Point(x=1, y=2) ('x', 'y') ``` +**[`Back To Contents`](#Contents)** Range ----- @@ -182,6 +185,7 @@ from_inclusive = .start to_exclusive = .stop ``` +**[`Back To Contents`](#Contents)** Enumerate --------- @@ -190,6 +194,7 @@ for i, el in enumerate( [, i_start]): ... ``` +**[`Back To Contents`](#Contents)** Iterator -------- @@ -221,6 +226,7 @@ from itertools import count, repeat, cycle, chain, islice = islice(, from_inclusive, …) # `to_exclusive, step_size`. ``` +**[`Back To Contents`](#Contents)** Generator --------- @@ -240,6 +246,7 @@ def count(start, step): (10, 12, 14) ``` +**[`Back To Contents`](#Contents)** Type ---- @@ -299,6 +306,7 @@ True +--------------------+----------+----------+----------+----------+----------+ ``` +**[`Back To Contents`](#Contents)** String ------ @@ -348,6 +356,7 @@ String ``` * **Also: `'isspace()'` checks for `'[ \t\n\r\f\v\x1c-\x1f\x85…]'`.** +**[`Back To Contents`](#Contents)** Regex ----- @@ -387,6 +396,7 @@ import re '\s' == '[ \t\n\r\f\v]' # Matches whitespaces. ``` +**[`Back To Contents`](#Contents)** Format ------ @@ -480,6 +490,7 @@ Format {90:X} # '5A' ``` +**[`Back To Contents`](#Contents)** Numbers ------- @@ -540,6 +551,7 @@ from random import random, randint, choice, shuffle, gauss, seed = ~ # Not (also: - - 1) ``` +**[`Back To Contents`](#Contents)** Combinatorics ------------- @@ -582,6 +594,7 @@ from itertools import product, combinations, combinations_with_replacement, perm ('c', 'a'), ('c', 'b')] # c x x . ``` +**[`Back To Contents`](#Contents)** Datetime -------- @@ -661,6 +674,7 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary = / # How many weeks/years there are in TD. Also '//'. ``` +**[`Back To Contents`](#Contents)** Arguments --------- @@ -678,6 +692,7 @@ def f(): # def f(x=0, y=0): def f(, ): # def f(x, y=0): ``` +**[`Back To Contents`](#Contents)** Splat Operator -------------- @@ -746,6 +761,7 @@ def f(x, *args, z, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3 head, *body, tail = ``` +**[`Back To Contents`](#Contents)** Inline ------ @@ -811,6 +827,7 @@ Creature = make_dataclass('Creature', ['loc', 'dir']) creature = Creature(point, direction) ``` +**[`Back To Contents`](#Contents)** Imports ------- @@ -823,6 +840,7 @@ import . # Imports a built-in or '/.py'. * **On a filesystem this corresponds to a directory of Python files with an optional init script.** * **Running `'import '` does not automatically provide access to the package's modules unless they are explicitly imported in its init script.** +**[`Back To Contents`](#Contents)** Closure ------- @@ -880,6 +898,7 @@ def get_counter(): (1, 2, 3) ``` +**[`Back To Contents`](#Contents)** Decorator --------- @@ -944,6 +963,7 @@ def add(x, y): return x + y ``` +**[`Back To Contents`](#Contents)** Class ----- @@ -1077,6 +1097,7 @@ from copy import copy, deepcopy = deepcopy() ``` +**[`Back To Contents`](#Contents)** Duck Types ---------- From ce45d2f23ed7fe740950467061bb273dc044e3b6 Mon Sep 17 00:00:00 2001 From: lucastucker-umd <85323213+lucastucker-umd@users.noreply.github.com> Date: Wed, 8 Dec 2021 18:52:05 -0500 Subject: [PATCH 4/4] Added the rest of the buttons --- README.md | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/README.md b/README.md index d607e035e..c6d14cd75 100644 --- a/README.md +++ b/README.md @@ -1230,6 +1230,7 @@ class MyOpen: Hello World! ``` +**[`Back To Contents`](#Contents)** Iterable Duck Types ------------------- @@ -1324,6 +1325,7 @@ class MyAbcSequence(abc.Sequence): * **Other ABCs that generate missing methods are: MutableSequence, Set, MutableSet, Mapping and MutableMapping.** * **Names of their required methods are stored in `'.__abstractmethods__'`.** +**[`Back To Contents`](#Contents)** Enum ---- @@ -1377,6 +1379,7 @@ LogicOp = Enum('LogicOp', {'AND': partial(lambda l, r: l and r), ``` * **Member names are in all caps because trying to access a member that is named after a reserved keyword raises SyntaxError.** +**[`Back To Contents`](#Contents)** Exceptions ---------- @@ -1491,6 +1494,7 @@ class MyInputError(MyError): pass ``` +**[`Back To Contents`](#Contents)** Exit ---- @@ -1502,6 +1506,7 @@ sys.exit() # Prints to stderr and exits with 1. sys.exit() # Exits with passed exit code. ``` +**[`Back To Contents`](#Contents)** Print ----- @@ -1518,6 +1523,7 @@ pprint(, width=80, depth=None, compact=False, sort_dicts=True) ``` * **Levels deeper than 'depth' get replaced by '...'.** +**[`Back To Contents`](#Contents)** Input ----- @@ -1530,6 +1536,7 @@ Input * **Prompt string is printed to the standard output before reading input.** * **Raises EOFError when user hits EOF (ctrl-d/ctrl-z⏎) or input stream gets exhausted.** +**[`Back To Contents`](#Contents)** Command Line Arguments ---------------------- @@ -1556,6 +1563,7 @@ value = args. * **Use `'default='` to set the default value.** * **Use `'type=FileType()'` for files.** +**[`Back To Contents`](#Contents)** Open ---- @@ -1621,6 +1629,7 @@ def write_to_file(filename, text): file.write(text) ``` +**[`Back To Contents`](#Contents)** Paths ----- @@ -1701,6 +1710,7 @@ from pathlib import Path = open() # Opens the file and returns file object. ``` +**[`Back To Contents`](#Contents)** OS Commands ----------- @@ -1757,6 +1767,7 @@ CompletedProcess(args=['bc', '-s'], returncode=0) '2\n' ``` +**[`Back To Contents`](#Contents)** JSON ---- @@ -1782,6 +1793,7 @@ def write_to_json_file(filename, an_object): json.dump(an_object, file, ensure_ascii=False, indent=2) ``` +**[`Back To Contents`](#Contents)** Pickle ------ @@ -1807,6 +1819,7 @@ def write_to_pickle_file(filename, an_object): pickle.dump(an_object, file) ``` +**[`Back To Contents`](#Contents)** CSV --- @@ -1872,6 +1885,7 @@ def write_to_csv_file(filename, rows): writer.writerows(rows) ``` +**[`Back To Contents`](#Contents)** SQLite ------ @@ -1939,6 +1953,7 @@ from mysql import connector .execute('', ) # Replaces '%()s's with values. ``` +**[`Back To Contents`](#Contents)** Bytes ----- @@ -1981,6 +1996,7 @@ def write_bytes(filename, bytes_obj): file.write(bytes_obj) ``` +**[`Back To Contents`](#Contents)** Struct ------ @@ -2023,6 +2039,7 @@ b'\x00\x01\x00\x02\x00\x00\x00\x03' * **`'f'` - float (4/4)** * **`'d'` - double (8/8)** +**[`Back To Contents`](#Contents)** Array ----- @@ -2037,6 +2054,7 @@ from array import array .write() # Writes array to the binary file. ``` +**[`Back To Contents`](#Contents)** Memory View ----------- @@ -2068,6 +2086,7 @@ Memory View '' = .hex() # Treats mview as a bytes object. ``` +**[`Back To Contents`](#Contents)** Deque ----- @@ -2085,6 +2104,7 @@ from collections import deque .rotate(n=1) # Rotates elements to the right. ``` +**[`Back To Contents`](#Contents)** Threading --------- @@ -2153,6 +2173,7 @@ from queue import Queue = .get_nowait() # Raises queue.Empty exception if empty. ``` +**[`Back To Contents`](#Contents)** Operator -------- @@ -2177,6 +2198,7 @@ last_element = op.methodcaller('pop')() * **They only work on objects with and(), or(), xor() and invert() special methods.** * **Also: `' = &|^ '` and `' = &|^ '`.** +**[`Back To Contents`](#Contents)** Introspection ------------- @@ -2208,6 +2230,7 @@ from inspect import signature = .kind # Member of ParameterKind enum. ``` +**[`Back To Contents`](#Contents)** Metaprogramming --------------- @@ -2295,6 +2318,7 @@ MyMetaClass.__base__ == type # MyMetaClass is a subclass of type. +-------------+-------------+ ``` +**[`Back To Contents`](#Contents)** Eval ---- @@ -2306,6 +2330,7 @@ Eval ValueError: malformed node or string ``` +**[`Back To Contents`](#Contents)** Coroutines ---------- @@ -2372,6 +2397,7 @@ if __name__ == '__main__': ```
+**[`Back To Contents`](#Contents)** Libraries ========= @@ -2387,6 +2413,7 @@ Progress Bar Processing: 100%|████████████████████| 3/3 [00:03<00:00, 1.00s/it] ``` +**[`Back To Contents`](#Contents)** Plot ---- @@ -2400,6 +2427,7 @@ plt.show() # Displays the figure. plt.clf() # Clears the figure. ``` +**[`Back To Contents`](#Contents)** Table ----- @@ -2414,6 +2442,7 @@ with open('test.csv', encoding='utf-8', newline='') as file: print(table) ``` +**[`Back To Contents`](#Contents)** Curses ------ @@ -2443,6 +2472,7 @@ if __name__ == '__main__': wrapper(main) ``` +**[`Back To Contents`](#Contents)** Logging ------- @@ -2487,6 +2517,7 @@ retention=|| * **`''` - Max age of a file.** * **`''` - Max age as a string: `'1 week, 3 days'`, `'2 months'`, ...** +**[`Back To Contents`](#Contents)** Scraping -------- @@ -2511,6 +2542,7 @@ except requests.exceptions.ConnectionError: print("You've got problems with connection.", file=sys.stderr) ``` +**[`Back To Contents`](#Contents)** Web --- @@ -2563,6 +2595,7 @@ def send_json(sport): ['arsenal f.c.', 2.44, 3.29] ``` +**[`Back To Contents`](#Contents)** Profiling --------- @@ -2632,6 +2665,7 @@ with PyCallGraph(drawer): ``` +**[`Back To Contents`](#Contents)** NumPy ----- @@ -2732,6 +2766,7 @@ right = [[0.1, 0.6, 0.8], [0.1, 0.6, 0.8], [0.1, 0.6, 0.8]] # Shape: (3, 3) <- [1, 2, 1] ``` +**[`Back To Contents`](#Contents)** Image ----- @@ -2808,6 +2843,7 @@ from PIL import ImageDraw * **Use `'outline='` to set the color of the contours.** * **Colors can be specified as an int, tuple, `'#rrggbb[aa]'` string or a color name.** +**[`Back To Contents`](#Contents)** Animation --------- @@ -2828,6 +2864,7 @@ frames += reversed(frames[1:-1]) imageio.mimsave('test.gif', frames, duration=0.03) ``` +**[`Back To Contents`](#Contents)** Audio ----- @@ -2934,6 +2971,7 @@ engine.say('Sally sells seashells by the seashore.') engine.runAndWait() ``` +**[`Back To Contents`](#Contents)** Synthesizer ----------- @@ -2956,6 +2994,7 @@ samples_b = b''.join(struct.pack(' = .sum/max/mean() # Or: .apply/agg() ``` +**[`Back To Contents`](#Contents)** Plotly ------ @@ -3467,6 +3508,7 @@ if __name__ == '__main__': main() ``` +**[`Back To Contents`](#Contents)** PySimpleGUI ----------- @@ -3479,6 +3521,7 @@ event, values = window.read() print(f'Hello {values[0]}!' if event == 'Ok' else '') ``` +**[`Back To Contents`](#Contents)** Appendix -------- @@ -3554,9 +3597,12 @@ if __name__ == '__main__': main() ``` +**[`Back To Contents`](#Contents)** Index ----- * **Only available in the [PDF](https://transactions.sendowl.com/products/78175486/4422834F/view).** * **Ctrl+F / ⌘F is usually sufficient.** * **Searching `'#'` on the [webpage](https://gto76.github.io/python-cheatsheet/) will limit the search to the titles.** + +**[`Back To Contents`](#Contents)**