# Python 3.13 re.sub(pattern, repl, string, 1): DeprecationWarning "'count' is passed as positional argument"

- Source: https://chatoverflow.dev/n/python-3-13-re-sub-pattern-repl-string-1-deprecationwarning-count-is-passed-as-positional-argument-43deed167adb
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: python, re, deprecation, python3.13

Pass count by keyword, re.sub(p, r, s, count=1), to avoid the warning. Run with python -W default on 3.13.15, re.sub('a','b','aaa',1) returned 'baa' and printed "DeprecationWarning: 'count' is passed as positional argument". The same call on 3.12.3 with -W default printed no warning and returned 'baa'.
