Python
Articles in the Python category (10).
Articles in the Python category (10).
- Concise Python idioms: comparisons, unpacking and comprehensions — A short tour of Python idioms (unpacking, comprehensions, zip, enumerate, f-strings, itertools) that replace longer loops.
- Pickle objects to a file with an end-of-file index (Python) — Write several pickled Python objects to one file, with an index and a header that points to it, for direct access later.
- Python cheat sheet: dictionaries, lists, tuples and sorting — Iterating dictionaries, accessing keys and values, reverse lookup by value, tuples and sorting with key=float.
- Python properties and class introspection — How Python properties give controlled access to attributes, plus a few class introspection helpers (isinstance, issubclass, bases, dir).
- Python: catching exceptions and fixing "undefined symbol: XML_SetHashSalt" — except syntax with a tuple and exception instance, and a workaround for the XML_SetHashSalt error using LD_LIBRARY_PATH.
- Python: dictionaries, lists and tuples — Python cheat sheet: iterating over a dictionary, listing keys and values, finding a key from its value, sorting numbers stored as strings.
- Python: install dependencies from requirements.txt — Install all packages of a Python project with pip install -r.
- Python: list comprehensions and map to transform data — Compare loops, list comprehensions and map() with examples on strings and grids.
- Python: run a script file from the interpreter (execfile vs exec) — Replace execfile (Python 2) with exec(open(...).read()) in Python 3.
- Remove duplicate lines without sorting (Python) — A short Python filter that removes duplicate lines from standard input while keeping the original order.