ZeroHour
Simon Willisonpublished ()ingested

Soft-deprecating re.match()

infoOtherimportance 15
AI summary · glm-5.3-flash

Python 3.15 soft-deprecates re.match(), introducing the clearer alternative re.prefixmatch()

Python 3.15 release manager Hugo van Kemenade announced that re.match() is being soft-deprecated, meaning new code should avoid it but it will not be removed. A clearer function, re.prefixmatch(), reflects the anchoring behavior at the start of the string. Developers are advised to prefer re.search() or re.fullmatch() in most cases.

  • Python 3.15 soft-deprecates re.match() without any promise of removal
  • New re.prefixmatch() name clarifies start-anchored, non-end-anchored matching
  • re.search() or re.fullmatch() usually better fits common use cases
Full article

Soft-deprecating re.match() Python has a concept of soft deprecation , where APIs are marked as "should no longer be used to write new code" without any promise/threat to remove them in the future. Python 3.15 release manager Hugo van Kemenade describes how in the upcoming 3.15 release soft deprecation has come for the venerable but deeply confusing re.match() function. It's now available with the much clearer alternative re.prefixmatch() name - reflecting how it anchors at the beginning of the string but not the end. Most of the time you probably want re.search() (match this pattern anywhere in the string) or re.fullmatch() (match the entire string) instead. Tags: python ,…

This source does not provide full text. Read it at simonwillison.net.