Python drops πŸπŸ’§

A daily drop of Python knowledge

Become smarter about Python

Get a short, actionable Python tip each day. Tips are short (under 100 words), actionable (you can apply them right away) and they're also sent as a flashcard, ideal if you're a visual learner.

Become smarter about Python πŸπŸ’§

What readers have to say

Andrew Hartung

The diagrams are always so well done they don't even need supporting text.

β€” Andrew Hartung – Python drops subscriber

Roberto Polli

I always recommend Rodrigo's posts to friends and colleagues.

Newcomers will learn Python concepts in an engaging way, and experienced programmers can refresh their knowledge and even learn something new about latest Python releases.

Thanks Rodrigo!

β€” Roberto Polli – Python drops subscriber

Sean

This is a great daily read regardless of your Python level. Within a minute or two; you are introduced to a language component or mechanism, a common use case for it, and example code demonstrating it.

β€” Sean – Staff Engineer for an American Telco, Python drops subscriber

Nico Belgraver

Quality and fun. Highly recommended!

β€” Nico Belgraver – NavApp, Python drops subscriber

Alexandre B A Villares

Rodrigo, your "tip cards" have been smashing, elegant and informative! Thank you for sharing them!

β€” Alexandre B A Villares – Python teacher, Python drops subscriber

David Thorvaldsen

I really enjoy your Python drops! So much new exposure to what's possible with the language!

β€” David Thorvaldsen – AI/ML Data Scientist @ Caterpillar Inc., Python drops subscriber

Robert Lucente

Love the short to the point code snippets. Then you really bring it home with graphics. Just awesome.

β€” Robert Lucente – Author of The Bit Plumber, Python drops subscriber

Roberto

Very interesting, looks like every time I read your posts I learn something new!

β€” Roberto – Python drops subscriber

Flashcards for visual learners

A horizontal composition of diagrams of 5 older tips.
Flashcards from previous tips.

Past tips

  1. Extracting text data into a dict
  2. Verbose regular expressions
  3. Structural validation and homogenisation
  4. Bulk renaming files
  5. Typing overloads
  6. Undoable iterator with value history
  7. Match an exact dictionary structure
  8. Built-in next with a default value
  9. Match the structure of custom objects
  10. Peek at an iterable
  11. Slicing generators for debugging
  12. Structural pattern matching with dictionaries
  13. File discovery by name pattern
  14. Extract assignments from conditionals
  15. Regex multiline flag
  16. Split strings in two halves
  17. Generator recipe
  18. Concatenate files from handlers
  19. Formatting dates with f-strings
  20. Resolving paths
  21. Named groups in regex
  22. Formatting big numbers
  23. One-shot file I/O
  24. File tail
  25. Idiomatic sequence slicing
  26. Subclassing immutable types
  27. Underscore in the REPL
  28. Ergonomic multiline strings
  29. Structural unpacking
  30. t-strings need processing
  31. Module itertools categorisation
  32. Case-insensitive regular expressions
  33. String constants
  34. Dynamic regex replacements
  35. Random choices
  36. Redacting email addresses
  37. Batching API calls
  38. Dot product idiom
  39. Counting values that satisfy a predicate
  40. Format specifier !r
  41. Read files in chunks
  42. Bounded cache
  43. Longest and shortest
  44. OS-agnostic line splitting
  45. Automatic enumeration values
  46. Global enumeration members
  47. Multi-dictionary
  48. Typing iterables instead of lists
  49. Inline lists and tuples
  50. Transpose a list of lists
  51. Normalise strings by removing accents
  52. Most recently-modified file
  53. Enumerations of string values
  54. Return value of a generator
  55. Use Literal for options
  56. Flag enumerations
  57. Enforce keyword arguments for options
  58. Notify parent class when subclassing
  59. Dynamic attribute manipulation
  60. Longest word in a string
  61. Chain multiple dictionaries
  62. Set operations with dict.keys()
  63. Current date and time
  64. Dunder attribute __file__
  65. Self-debugging f-strings
  66. Immutable dictionary
  67. Create context managers with contextlib.contextmanager
  68. Type statements
  69. Round to pretty whole numbers
  70. Multiple options in a single case statement
  71. String prefixes and suffixes
  72. Run-length encoding
  73. Count characters in a file
  74. Remove punctuation from a string
  75. map with multiple arguments
  76. Schedule cleanup actions
  77. Unique elements from a list
  78. Last element that satisfies a condition
  79. First element that satisfies a condition
  80. Parsing integers from different bases
  81. Type unions with the vertical bar in isinstance
  82. Case-insensitive string comparisons
  83. zip's keyword argument strict

Refer readers, access the tip backlog

The mathspp drops πŸπŸ’§ newsletter is free. That's 5 tips per week, for free.

If you refer your friends and colleagues to the mathspp drops πŸπŸ’§ newsletter, you can earn rewards. For example, you can earn access to the backlog of tips (started on the 4th of March of 2025), which is available as an e-book and as a set of flashcards.

To refer friends, check the instructions on the bottom of every tip email you receive.

E-book version

The backlog of tips (started on the 4th of March of 2025) can be purchased as an e-book (in PDF and EPUB formats) and as a PDF with the set of flashcards.

Subscribe