TIL (Today I Learned)

The TIL series of articles contains very short articles documenting something I learned “today”.

Today I learned that the hash of an integer is the integer itself, except for -1. The hash of -1 is -2.

Today I learned how to allow my custom objects to be unpacked into keyword arguments like '**kwargs'.

Today I learned how to use the Polars function pl.date_range to create date sequences with calendar-aware intervals between dates.

Today I learned how to use shell scripting to activate my virtual environment automatically when I change directories.

Today I learned about the behaviour of asyncio.gather.

Today I learned about 5 useful pytest options that let me control what tests to run with respect to failing tests.

Today I learned how to debug the new Python REPL with _pyrepl.trace and the environment variable PYREPL_TRACE.

Today I learned how to fix an issue with Ctrl+left and Ctrl+right not working in the new Python REPL on MacOS.

Today I learned the difference between __getattr__ and __getattribute__.

You can use the Python built-in function iter with two arguments to create an iterator from a function.

Today I learned how to order the values of a dictionary according to an iterable of keys.

Today I learned how to get the size of the terminal your code is running on.

Today I learned how to use named tuples to improve readability and flexibility of test parametrisations in pytest.

Today I learned about the parameter match used in pytest.raises.

Today I learned how to use the function operator.methodcaller.

Today I learned how to use the dunder method __init_subclass__ to be notified when a class is subclassed.

Today I learned how to issue user warnings like DeprecationWarnings or SyntaxWarnings.

Yesterday I spent the whole day tryint to patch a module global. This is what I ended up with.

Today I learned how many soft keywords Python has and what they are.

Today I learned that the underscore _ is a soft keyword in Python.