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

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