serhii.net
In the middle of the desert you can say anything you want
Home page
Blog
Work log
Journal
Link blog
Projects
About
tags: Python
Black unstable features
mypy notes
Setting up pylint as external tool in pycharm
File is not reserved in python anymore
flake8 and docstrings
Huggingface Hub prefers zip archives because they support streaming
Huggingface dataset build configs
python random sample vs random choices
Pandas adding prefix to columns and making metadata out of column subsets
Spacy has both Token.lemma_ and Token.norm_
rich inspect
Sorting Ukrainian words in Python
Spacy has an attribute_ruler to force specific changes in matches
Formatting floats as strings inside a list comprehension
pytest approx as almostequal
Poetry installing packages as -e ditable
Dumping pretty cyrillic UTF YAML and JSON files
I am not forced to do dict.items() all the time
Rounding rules and notations
Perceptual image hashes
Poetry add spacy model to requirements
poetry running scripts after building python package
Pytest logging output through CLI
Tenacity: a retrying library for python
GBIF API bits
Notes to self and lessons learned, OOP and programming in general
requests and urllib333 exceptions adventures
You can add notes to exceptions
Overengineered solution to retrying and exceptions in python
Pip can easily install packages from github
Passing booleans to python argparse as str
pytest and lru_cache
python progressbar2
llm python module for CLI llm or chatGPT use
Tqdm and logging
tqdm for iterators with known lengths; manual updating
poetry add version requirements
Adventures in UTF8
Python self type
Everything I know about saving plots in matplotlib, seaborn, plotly, as PNG and vector PDF/EPS etc.
Timing stuff in jupyter
You can add underscores to numbers in Python
pip force reinstall
Black for jupyter notebook
Huggingface datasets can become pandas dataframes
Pandas categorical types weirdness
Pandas joining and merging tables
Pandas seaborn plotting groupby can be used without reset_index
Pandas set column value based on (incl.groupby) filter
seaborn things built on FacetGrid for easy multiple plots
Pandas add colums to dataframe based on dictionary inside a column
Python 3.10 has a case statement
pycharm reformat file
Pandas and jupyter basics I keep looking for: display all rows/cols and make cells 100% wide
Seaborn basics
seaborn plotting pandas pd.Timedeltas
Black failing with error about safe mode
Python collections, typing etc.
matplotlib labeling pie-charts
Python Callable Protocols for complex Callable typing
Python ellipsis (...)
Python state machine
pytest skipif
pyenv basics
Enums in python - set by name and value
Python raise_or_log function
Python blending abstractmethod and staticmethod (or other decorators)
Python typing annotating functions and callables
Python path .resolve() doesn't expand ~, only .. and symlinks!
Python logging filters
Python logging to file and screen with different loglevels
Python @property decorator
Python logging change level through context manager
Python pattern fail on multiple conditions
Python pathlib Path check if directory is empty
Omegaconf and python configs
Pycharm shelf and changelists and 'Unshelve silently'
Python fnmatch glob invalid expressions
Running modules with pdbpp in python
Huggingface utils ExplicitEnum python bits
Creating representative test sets
Pycharm pytest logging settings
Python sorted sorting with multiple keys
Python dataclass libraries, pydantic and dataclass-wizard
Python typing classmethods return type
Python for..else syntax
Python interval libraries
Python str lower bug - callable function vs function return value
Python argparse pass multiple values for argument
Python set operations
Huggingface Datasets metadata
Directory structure for python research-y projects
Python unpacking operator to get list of dictionary keys from dict_keys
Pycharm drop into the debugger on failed tests
Pytest fixtures that yield instead of return for better cleanup code
pytest-print to print strings when running pytests
Python parse library that's the opposite of formatted strings
Qtile replacing countdown-notification mechanism
HF datasets intro google colab
pycharm nagging me about TODOs before committing might actually be useful
python sanitizing filenames with external library
python defaultdict
Using pytest markers in pycharm
Python add duplicate function names for backwards compatibility
pytest temporary files
Pycharm explicitly calling breakpoint() during debugging
Python running modules inside modules from CLI
Pycharm use requirements.txt
Streamlit for small python demos
Use tqdm only if the list is large
argparse does prefix matching
pytest sharing data between test files through pytest.configure
python asserts
python run pdb on exception
python walrus operators for debugging and output
taskwarrior getting currently active task
Setting up pycharm for poetry, black etc.
Taskwarrior python bindings
pytest fixture to make pytest-datafiles return a pathlib.Path
pytest use conftest.py to run python code before the tests
Using pytest-datafiles for assets in pytest
Easier python logging setup with argparse's 'dest' parameter
Python package import patterns link + __init__ stuff
python logging explanation of the relationship between root logger and submodule ones
python pdb stops on keyboard interrupt
pdppp instead of pdb and ipdb for python debugging
Python expanding a list by assigning multiple elements to a slice
First use of python 3.8 walrus operator!
python None in slice notation
mypy disabling individual warnings
Python best practices for 2021
Python click getting default values from config file
Python dotenv and python-decouple to separate configs from code
IPDB move through individual frames
IPython
Python Union typing
python import this
Python pytest workshop part 2
Convert nested OrderedDicts into dict
211207-1822 Three ways to return None in python
211201-1637 mypy and python typing
211124-1731 python logging setup
211124-1744 argparse notes
211123-2333 python scopes
211123-2345 python packaging
211123-2348 poetry for package management
211118-0024 python namedtuple
211117-1127 python simple TTL time-based caching
211117-1926 python staticmethods and self
211117-2327 python annotating number of elements in Tuple, Sequence, List in typing
211108-1212 nvidia-smi has a python library (bindings)
211102-0111 python defining own types for typing
211102-1811 python pip and wheel
211028-1110 Python staticmethod vs classmethod
211018-1510 Python rounding behaviour