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