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

Elias Dorneles

I very much enjoy receiving Rodrigo's Python tips on my email. They're bite-sized and informative, just great as a daily dopamine hit!

β€” Elias Dorneles – Python drops subscriber

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