Rico's Nerd Cluster

「离开世界之前 一切都是过程」

Python - Python Packaging System

Packaging

Setuptools Entrypoints Entrypoints are a way to specify components in your package to the rest of the python space, so they can be dynamically discovered. So this enables: Console scripts (co...

Python - Poetry Packaging System and Pip

Poetry, Pip

Introduction Using Poetry is highly recommended because it simplifies dependency management and packaging, even when not using virtual environments. Environments without Poetry can install poetry ...

Python - How To Write Pytest

Pytest Is The New Black (Compared To Unittest)

Run Pytest Run a specific test file pytest path/to/test_file.py Run a test in it: pytest path/to/test_file.py::test_function_name Assert For integer assertions: 1 assert (1==1) F...

Python - Enums

Enum, IntEnum

IntEnum IntEnum’s members are ints, while enum instance’s members are its own class Enum: Base class for creating enumerated constants. IntEnum: Base class for creating enumera...

Python - Python Iterables

Iterable, Itertools, Round Robin Counter

What is An Iterable An iterable is any object that returns an iterator, which allows you to iterate its elements. Some common examples include lists, dictionaries, sets, and strings. Iterating ove...

Python - Jupyter Notebook Common Magic Commands

Jupyter Notebook Common Magic Commands

Magic command %command is a function in IPython. Make sure matplotlib is rendered inline Immediately autoreload modules if they are changed outside 1 2 3 4 5 6 7 8 9 10 11 %matplotlib inlin...

Python - Python Misc, os, shutil

Sys, Print, Argparse Path-Related Utils

sys Check current python version 1 2 3 4 if sys.version_info.major == 3 and sys.version_info.minor == 10: print("Python version is 3.10") else: print(f"Python version is not 3.10, it'...

Python - Functions

Map-Reduce-Filter, Lambda (Under Active Updates)

Map, Reduce, Filter Map, Reduce, Filter are paradigms of functional programming. WIth them, we can write simpler and shorter programs. They are applied on iterables. Map map(callable, iterable) ...

Google Drive

Shortcuts

Shortcuts Make fonts larger: ctrl-shift-.

Git

Gitalk

Gitalk Gitalk is a free, open-source commenting system that uses GitHub issues for comment storage. It’s an excellent option for developers hosting websites on platforms like GitHub Pages. Cre...