GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Allow `str.replace`'s 'count' to be a keyword argument · Issue #106487 · python/cpython

Allow str.replace's 'count' to be a keyword argument #106487

New issue
Copy link
New issue
Copy link
Closed
Closed
Allow str.replace's 'count' to be a keyword argument#106487
Copy link
Labels
3.13only security fixesonly security fixestype-featureA feature request or enhancementA feature request or enhancement

Description

@hugovk
hugovk
opened on Jul 6, 2023
Issue body actions

Feature or enhancement

Allow the count argument of str.replace to be a keyword to better describe its use.

Pitch

str.replace takes old and new strings as parameters, and an optional count parameter:

https://docs.python.org/3/library/stdtypes.html#str.replace

However, count cannot be a keyword argument:

>>> "aaa".replace("a", "b", 2)
'bba'
>>> "aaa".replace("a", "b", count=2)
TypeError: str.replace() takes no keyword arguments

It would be more explicit if the count parameter could also be a keyword, so there's no doubt about its meaning.

Previous discussion

Suggested by @treyhunner at https://mastodon.social/@treyhunner/110664375381530126

Linked PRs

  • gh-106487: Allow the 'count' argument of str.replace to be a keyword #106488
Reacted by Alex Waygood, Trey Hunner, Jürgen Gmach, Tushar Sadhwani, Will., Charlie Zhao, sunmy2019, Kevin Bowen, Raymond Hettinger, Degubi and 5 more

Activity

  1. hugovk
    added
    type-featureA feature request or enhancementA feature request or enhancement
    3.13only security fixesonly security fixes
    on Jul 6, 2023
  2. hugovk
    changed the title [-]Allow `str.replace`'s `count` to be a keyword argument[/-] [+]Allow `str.replace`'s 'count' to be a keyword argument[/+] on Jul 6, 2023
  3. hugovk
    added a commit that references this issue on Jul 10, 2023

    gh-106487: Allow the 'count' argument of `str.replace` to be a keyword (

    34c1414
  4. hugovk commented on Jul 10, 2023

    @hugovk
    hugovk
    on Jul 10, 2023
    MemberAuthor
    More actions

    Implemented in PR #106488 for Python 3.13, due October 2024.

    https://devguide.python.org/versions/

    Reacted by Doug Mellon
  5. hugovk
    closed this as completedon Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13only security fixesonly security fixestype-featureA feature request or enhancementA feature request or enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.