python
Python programming language and libraries
Pretty-print JSON in shell scripts using jq, Python's json.tool, php or json_pp. One-line examples for bash, curl, NDJSON and safe in-place file updates.
Discover the best way to get the last element of a Python list using negative indexing alist[-1]. Compare with alist[len(alist)-1], performance, best practices, and edge cases for efficient list handling.
Learn how to convert datetime strings like 'Jun 1 2005 1:33PM' to Python datetime objects using strptime, pandas.to_datetime, and dateutil.parser. Handle lists, edge cases, AM/PM, and locales efficiently.
Learn to print colored text in Python terminal using ANSI escape codes, termcolor, and colorama for python colored print. Cross-platform examples, troubleshooting, and best practices for python print color text.
List files in a directory with Python. Examples use os.listdir, pathlib, glob, and os.scandir. Store results in a list, filter by extension, and recurse.
Learn how to add new keys to a Python dictionary using assignment, update(), setdefault(), and merge operators. No dict.add() method—use these efficient idioms for key-value pairs with examples and pitfalls.
Learn mkdir -p equivalents to create a directory and missing parent directories in Linux/macOS, Python (os.makedirs), PowerShell (New-Item), Node.js, Java. Avoid race conditions with exist_ok=True.
Learn what metaclasses are in Python, how they work as the class of a class, and their uses like automatic registries, ORM mapping, and framework enforcement. Examples included.
Resolve pip uninstall error for databricks-dlt in Databricks: 'No input was expected ($PIP_NO_INPUT set)'. Use %pip uninstall -y databricks-dlt, restart Python with dbutils.library.restartPython(), and handle cluster libraries.