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

James Sheldon

I discovered Rodrigo’s Python drops as I was exploring new features of Python 3.14.0 when it was in beta testing. I was trying to understand the new Placeholder class and found his drop about not only that topic but how it applies to partial.

His explanation was clear, concise and left me understanding a wonderful new Python feature. I’m a highly satisfied Python drops reader.

β€” James Sheldon – Python drops reader

Martin Schorfmann

The "Python Drops" format of one easily digestable topic at a time with code snippets is quite good.

β€” Martin Schorfmann – Software Developer, Python drops subscriber

Nacho Caballero

Rodrigo is a consistent source of generous, high‑quality technical insights about the [Python] language we know and love.

β€” Nacho Caballero – Python drops subscriber

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

Flashcards for visual learners

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

Past tips

  1. Oxford comma
  2. Truthy and Falsy
  3. Private members
  4. strftime vs strptime
  5. Controlled string splitting
  6. Chaining comparison operators
  7. Remote interactive debugging
  8. Check for None functionally
  9. min-heaps and max-heaps
  10. Parse dates from strings
  11. Error handling with multiple types
  12. Grouping digits in the fractional part
  13. asyncio introspection
  14. Custom t-string processing
  15. json CLI
  16. Compression algorithms
  17. Forward references in annotations
  18. Find similar words
  19. copy files
  20. Colour in the REPL
  21. NotImplementedError
  22. Set operations with operators
  23. String formatting field alignment
  24. Cycling over an iterable
  25. NotImplemented
  26. Safe random tokens
  27. Decimals
  28. Using fractions
  29. Regex matches across newlines
  30. Compute partial sums with accumulate
  31. Reduce boilerplate with dataclasses
  32. Alternative constructors as class methods
  33. Read-only attributes
  34. Strict batching
  35. Class and instance attributes
  36. Invertible flags
  37. Find files in a directory
  38. Efficiently count characters in a string
  39. Efficiently count words in a string
  40. Make numbers more readable
  41. Prevent subclassing/overriding
  42. pairwise generalisation
  43. Remove punctuation functionally
  44. Integer literals in multiple bases
  45. Enforce positional arguments
  46. Operate on two lists of numbers
  47. Using properties
  48. Ignore exceptions
  49. Paginate results
  50. All equal
  51. Efficiently extending a list
  52. Safely overriding methods
  53. Dictionary creation idiom
  54. Send data into generators
  55. Double leading underscore
  56. dict.fromkeys
  57. Constant variables
  58. Two-dimensional range
  59. Type hints that refer to functions
  60. Non-greedy regex quantifiers
  61. Add typing to decorators
  62. Dynamic module attribute look-up
  63. map's keyword argument strict
  64. Custom enum search behaviour
  65. Dunder method __missing__
  66. AST parsing
  67. Typing *args and **kwargs
  68. methods __str__ and __repr__
  69. Pretty-printing nested data structures
  70. Filtering Truthy values
  71. Readable object names
  72. Custom containment checks
  73. Match word boundaries
  74. Common __hash__ implementation
  75. Docstring __doc__ attribute
  76. Dynamic width string formatting
  77. Non-local variables
  78. Temporary directories
  79. Timestamp file names
  80. Preserving decorated function metadata
  81. Natural alphabetical sorting
  82. Constrained generics
  83. Caching sets and frozen sets
  84. File modes
  85. Add lists together, fast
  86. Generics syntax
  87. Extracting text data into a dict
  88. Verbose regular expressions
  89. Structural validation and homogenisation
  90. Bulk renaming files
  91. Typing overloads
  92. Undoable iterator with value history
  93. Match an exact dictionary structure
  94. Built-in next with a default value
  95. Match the structure of custom objects
  96. Peek at an iterable
  97. Slicing generators for debugging
  98. Structural pattern matching with dictionaries
  99. File discovery by name pattern
  100. Extract assignments from conditionals
  101. Regex multiline flag
  102. Split strings in two halves
  103. Generator recipe
  104. Concatenate files from handlers
  105. Formatting dates with f-strings
  106. Resolving paths
  107. Named groups in regex
  108. Formatting big numbers
  109. One-shot file I/O
  110. File tail
  111. Idiomatic sequence slicing
  112. Subclassing immutable types
  113. Underscore in the REPL
  114. Ergonomic multiline strings
  115. Structural unpacking
  116. t-strings need processing
  117. Module itertools categorisation
  118. Case-insensitive regular expressions
  119. String constants
  120. Dynamic regex replacements
  121. Random choices
  122. Redacting email addresses
  123. Batching API calls
  124. Dot product idiom
  125. Counting values that satisfy a predicate
  126. Format specifier !r
  127. Read files in chunks
  128. Bounded cache
  129. Longest and shortest
  130. OS-agnostic line splitting
  131. Automatic enumeration values
  132. Global enumeration members
  133. Multi-dictionary
  134. Typing iterables instead of lists
  135. Inline lists and tuples
  136. Transpose a list of lists
  137. Normalise strings by removing accents
  138. Most recently-modified file
  139. Enumerations of string values
  140. Return value of a generator
  141. Use Literal for options
  142. Flag enumerations
  143. Enforce keyword arguments for options
  144. Notify parent class when subclassing
  145. Dynamic attribute manipulation
  146. Longest word in a string
  147. Chain multiple dictionaries
  148. Set operations with dict.keys()
  149. Current date and time
  150. Dunder attribute __file__
  151. Self-debugging f-strings
  152. Immutable dictionary
  153. Create context managers with contextlib.contextmanager
  154. Type statements
  155. Round to pretty whole numbers
  156. Multiple options in a single case statement
  157. String prefixes and suffixes
  158. Run-length encoding
  159. Count characters in a file
  160. Remove punctuation from a string
  161. map with multiple arguments
  162. Schedule cleanup actions
  163. Unique elements from a list
  164. Last element that satisfies a condition
  165. First element that satisfies a condition
  166. Parsing integers from different bases
  167. Type unions with the vertical bar in isinstance
  168. Case-insensitive string comparisons
  169. 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