Skip to content

Docs: change functools.Placeholder import alias #160953

Closed as not planned
Closed as not planned

Description

@JadenV15

Documentation

The functools.partial() docs has the following example for using Placeholder with partial():

from functools import partial, Placeholder as _
remove = partial(str.replace, _, _, '')
message = 'Hello, dear dear world!'
remove(message, ' dear')

remove_dear = partial(remove, _, ' dear')
remove_dear(message)

remove_first_dear = partial(remove_dear, _, 1)
remove_first_dear(message)

The import alias import Placeholder as _ seems to be bad practice, as the underscore could easily conflict with temporary loop variables or a text translation function, both of which are usually named _.

I suggest using _P instead, which is also pretty convenient.

Activity

  1. added a commit that references this issue on Oct 30, 2026
    cf82f58
  2. picnixz commented on Oct 30, 2026

    @picnixz
    Member

    I like the _ better because it visually shows a placeholder. _P looks liks a private variable or private class.

  3. picnixz commented on Oct 30, 2026

    @picnixz
    Member

    As for conflicting with translations or unused vars, that should be changed accordingly in user code. For the example it is enough IMO.

  4. Omega-127 commented on Oct 30, 2026

    @Omega-127

    Looks interesting can I get assigned? Only if this issue is still doable

  5. picnixz commented on Oct 30, 2026

    @picnixz
    Member

    I do not think this will be something to change. At least I find _ rather better in the docs for that.

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

    docsDocumentation in the Doc dir

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions