<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>fluttersmith/py-snippets</title><description>Python snippets that still pass.</description><link>https://fluttersmith.github.io/</link><item><title>Split a list in two with a predicate</title><link>https://fluttersmith.github.io/py-snippets/s/bifurcate-by/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/bifurcate-by/</guid><description>Partition items into those that pass a test and those that don&apos;t, in one pass.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>splitting</category></item><item><title>Split a list into n chunks</title><link>https://fluttersmith.github.io/py-snippets/s/chunk-into-n/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/chunk-into-n/</guid><description>Split a sequence into exactly n lists whose sizes differ by at most one.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>splitting</category></item><item><title>Count items by a key</title><link>https://fluttersmith.github.io/py-snippets/s/count-by/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/count-by/</guid><description>Count how many items map to each key, using collections.Counter.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>counting</category><category>grouping</category></item><item><title>Flatten a nested list of any depth</title><link>https://fluttersmith.github.io/py-snippets/s/deep-flatten/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/deep-flatten/</guid><description>Lazily yield every value from arbitrarily nested iterables, treating strings as values.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>nested</category><category>iteration</category></item><item><title>List difference by a key</title><link>https://fluttersmith.github.io/py-snippets/s/difference-by/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/difference-by/</guid><description>Keep the items of one list whose key doesn&apos;t appear in another, preserving order.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>sets</category></item><item><title>Find duplicate and single values</title><link>https://fluttersmith.github.io/py-snippets/s/duplicates/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/duplicates/</guid><description>List the values that repeat, or the ones that appear exactly once.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>dedupe</category><category>counting</category></item><item><title>Every nth item of a list</title><link>https://fluttersmith.github.io/py-snippets/s/every-nth/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/every-nth/</guid><description>Take every nth item from a sequence, starting with the nth, using a slice.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>iteration</category></item><item><title>Group items by a key</title><link>https://fluttersmith.github.io/py-snippets/s/group-by/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/group-by/</guid><description>Bucket items into lists keyed by a function, keeping the original order inside each group.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>grouping</category></item><item><title>Check a list for duplicates</title><link>https://fluttersmith.github.io/py-snippets/s/has-duplicates/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/has-duplicates/</guid><description>Return True as soon as any value repeats, even in a huge or endless iterable.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>dedupe</category><category>validation</category></item><item><title>Check two lists hold the same items</title><link>https://fluttersmith.github.io/py-snippets/s/have-same-contents/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/have-same-contents/</guid><description>Compare two collections regardless of order, counting duplicates, in linear time.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>validation</category><category>counting</category></item><item><title>Find every index of a value</title><link>https://fluttersmith.github.io/py-snippets/s/index-of-all/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/index-of-all/</guid><description>Return all positions of a value, or of items matching a predicate.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>search</category></item><item><title>List intersection by a key</title><link>https://fluttersmith.github.io/py-snippets/s/intersection-by/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/intersection-by/</guid><description>Keep the items of one list whose key also appears in another, preserving order.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>sets</category></item><item><title>Find the most frequent value</title><link>https://fluttersmith.github.io/py-snippets/s/most-frequent/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/most-frequent/</guid><description>Return the most common item, breaking ties by first appearance.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>counting</category></item><item><title>Sort a list by a matching list of positions</title><link>https://fluttersmith.github.io/py-snippets/s/sort-by-indexes/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/sort-by-indexes/</guid><description>Order items by the number at the same position in a second list.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>sorting</category></item><item><title>List union by a key</title><link>https://fluttersmith.github.io/py-snippets/s/union-by/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/union-by/</guid><description>Merge two lists, keeping the first item for each key, in a predictable order.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>sets</category><category>dedupe</category></item><item><title>Remove duplicates and keep order</title><link>https://fluttersmith.github.io/py-snippets/s/unique-elements/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/unique-elements/</guid><description>De-duplicate a list while keeping the first occurrence of each value, in order.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>lists</category><category>dedupe</category></item><item><title>Invert a dictionary, keeping every key</title><link>https://fluttersmith.github.io/py-snippets/s/collect-dictionary/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/collect-dictionary/</guid><description>Invert a dict so each value maps to the list of keys that had it.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dicts</category><category>mapping</category><category>grouping</category></item><item><title>Find the keys for a value</title><link>https://fluttersmith.github.io/py-snippets/s/find-keys/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/find-keys/</guid><description>Return every key whose value equals a given value.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dicts</category><category>search</category></item><item><title>Get a value from nested data</title><link>https://fluttersmith.github.io/py-snippets/s/get-nested/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/get-nested/</guid><description>Follow a path of keys and indexes through nested dicts and lists, with a default.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dicts</category><category>nested</category><category>search</category></item><item><title>Invert a dictionary</title><link>https://fluttersmith.github.io/py-snippets/s/invert-dictionary/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/invert-dictionary/</guid><description>Swap keys and values with a dict comprehension; the last key wins on shared values.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dicts</category><category>mapping</category></item><item><title>Key of the largest or smallest value</title><link>https://fluttersmith.github.io/py-snippets/s/key-of-max/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/key-of-max/</guid><description>Find the key with the largest or smallest value using max() or min() with a key function.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dicts</category><category>search</category><category>sorting</category></item><item><title>Transform every value in a dict</title><link>https://fluttersmith.github.io/py-snippets/s/map-values/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/map-values/</guid><description>Build a new dict with a function applied to each value, keeping the keys.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dicts</category><category>mapping</category></item><item><title>Pluck one field from a list of dicts</title><link>https://fluttersmith.github.io/py-snippets/s/pluck/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/pluck/</guid><description>Collect the value of a key from each dict, with None where it&apos;s missing.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dicts</category><category>mapping</category><category>nested</category></item><item><title>Sort a dictionary by value</title><link>https://fluttersmith.github.io/py-snippets/s/sort-dict-by-value/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/sort-dict-by-value/</guid><description>Return a copy of a dict ordered by its values, ascending or descending.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dicts</category><category>sorting</category></item><item><title>Size of a string in bytes</title><link>https://fluttersmith.github.io/py-snippets/s/byte-size/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/byte-size/</guid><description>Count the bytes a string takes up once encoded, which len() doesn&apos;t tell you.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>strings</category><category>text</category></item><item><title>Hamming distance between strings</title><link>https://fluttersmith.github.io/py-snippets/s/hamming-distance/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/hamming-distance/</guid><description>Count the positions at which two equal-length strings differ.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>strings</category><category>text</category><category>counting</category></item><item><title>Convert between hex colours and RGB</title><link>https://fluttersmith.github.io/py-snippets/s/hex-rgb/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/hex-rgb/</guid><description>Parse #RRGGBB and #RGB colours into (r, g, b), and format them back.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>strings</category><category>conversion</category></item><item><title>Check if two strings are anagrams</title><link>https://fluttersmith.github.io/py-snippets/s/is-anagram/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/is-anagram/</guid><description>Compare letter counts, ignoring case, spaces and punctuation.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>strings</category><category>text</category><category>validation</category></item><item><title>Check if a string is a palindrome</title><link>https://fluttersmith.github.io/py-snippets/s/is-palindrome/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/is-palindrome/</guid><description>Check whether text reads the same reversed, ignoring case, spaces and punctuation.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>strings</category><category>text</category><category>validation</category></item><item><title>Convert between naming cases</title><link>https://fluttersmith.github.io/py-snippets/s/naming-cases/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/naming-cases/</guid><description>Convert text between snake_case, kebab-case, camelCase and PascalCase, acronyms included.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>strings</category><category>text</category><category>conversion</category></item><item><title>Turn text into a URL slug</title><link>https://fluttersmith.github.io/py-snippets/s/slugify/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/slugify/</guid><description>Make a lowercase, ASCII, hyphen-separated slug from any text, including accented letters.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>strings</category><category>text</category><category>conversion</category></item><item><title>Split a string into words</title><link>https://fluttersmith.github.io/py-snippets/s/words/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/words/</guid><description>Extract the words from text with a regex, keeping apostrophes and hyphens inside words.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>strings</category><category>text</category></item><item><title>Clamp a number to a range</title><link>https://fluttersmith.github.io/py-snippets/s/clamp-number/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/clamp-number/</guid><description>Limit a value to an inclusive range, accepting the bounds in either order.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>numbers</category><category>validation</category></item><item><title>Split a number into its digits</title><link>https://fluttersmith.github.io/py-snippets/s/digitize/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/digitize/</guid><description>Turn an integer into a list of its decimal digits.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>numbers</category><category>conversion</category></item><item><title>Check if a number is prime</title><link>https://fluttersmith.github.io/py-snippets/s/is-prime/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/is-prime/</guid><description>Test primality by trial division up to the integer square root.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>numbers</category><category>validation</category></item><item><title>Map a number from one range to another</title><link>https://fluttersmith.github.io/py-snippets/s/num-to-range/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/num-to-range/</guid><description>Linearly map a value from one range onto another, like Arduino&apos;s map().</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>numbers</category><category>conversion</category></item><item><title>Convert an integer to Roman numerals</title><link>https://fluttersmith.github.io/py-snippets/s/to-roman-numeral/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/to-roman-numeral/</guid><description>Convert 1 to 3999 into Roman numerals with a greedy table, rejecting values outside that range.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>numbers</category><category>conversion</category></item><item><title>Iterate over a range of dates</title><link>https://fluttersmith.github.io/py-snippets/s/daterange/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/daterange/</guid><description>Yield the dates from start up to end, like range() for days, with an optional step.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dates</category><category>calendar</category><category>iteration</category></item><item><title>Whole months between two dates</title><link>https://fluttersmith.github.io/py-snippets/s/months-diff/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/months-diff/</guid><description>Count complete calendar months between two dates, the way people count them.</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dates</category><category>calendar</category></item><item><title>Check for a weekday or weekend</title><link>https://fluttersmith.github.io/py-snippets/s/weekdays/</link><guid isPermaLink="true">https://fluttersmith.github.io/py-snippets/s/weekdays/</guid><description>Tell weekdays from weekends using date.weekday().</description><pubDate>Thu, 01 Oct 2026 00:00:00 GMT</pubDate><category>dates</category><category>calendar</category><category>validation</category></item></channel></rss>