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