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