返回全部动态
Python 3.15 软弃用 re.match(),新增 re.prefixmatch()
原标题:Soft-deprecating re.match()
AI 摘要
Python 3.15 发布经理 Hugo van Kemenade 介绍,即将发布的 3.15 版本对长期存在但容易混淆的 re.match() 函数进行软弃用,新增更清晰的替代名称 re.prefixmatch(),以反映其只锚定字符串开头而非结尾的行为。软弃用意味着该 API 被标记为不应再用于编写新代码,但不会承诺或威胁在未来移除。文章建议多数场景应改用 re.search() 或 re.fullmatch()。
以上摘要由 AI 生成,可能存在误差。事实请以原文为准。
正文节选
11th September 2026 - Link Blog 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, now available with the much clearer alternative re.prefixmatch() name - reflecting how it ancho
发布时间:2026-09-11 22:47
抓取时间:2026-09-11 22:50
来源机构:Simon Willison