Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Match doc: Clarify '_' as a soft keyword #88191

Closed
terryjreedy opened this issue May 4, 2021 · 4 comments
Closed

Match doc: Clarify '_' as a soft keyword #88191

terryjreedy opened this issue May 4, 2021 · 4 comments
Labels
3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@terryjreedy
Copy link
Member

BPO 44025
Nosy @gvanrossum, @terryjreedy, @ambv, @Mariatta, @pablogsal, @miss-islington, @brandtbucher
PRs
  • bpo-44025: Clarify when '_' is a keyword. #25873
  • [3.10] bpo-44025: Clarify when '_' is a keyword. (GH-25873) #25888
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-05-04.02:04:38.237>
    labels = ['3.11', 'type-bug', '3.10', 'docs']
    title = "Match doc: Clarify '_' as a soft keyword"
    updated_at = <Date 2021-07-18.15:30:45.096>
    user = 'https://github.com/terryjreedy'

    bugs.python.org fields:

    activity = <Date 2021-07-18.15:30:45.096>
    actor = 'pablogsal'
    assignee = 'docs@python'
    closed = False
    closed_date = None
    closer = None
    components = ['Documentation']
    creation = <Date 2021-05-04.02:04:38.237>
    creator = 'terry.reedy'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 44025
    keywords = ['patch']
    message_count = 3.0
    messages = ['392848', '392877', '392929']
    nosy_count = 8.0
    nosy_names = ['gvanrossum', 'terry.reedy', 'docs@python', 'lukasz.langa', 'Mariatta', 'pablogsal', 'miss-islington', 'brandtbucher']
    pr_nums = ['25873', '25888']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue44025'
    versions = ['Python 3.10', 'Python 3.11']

    @terryjreedy
    Copy link
    Member Author

    In bpo-44010, we are trying, as best as is possible with comprehensible REs, to identify in which circumstances occurrences of 'match', 'case' and '_' are keywords, and should be marked as such. I was initially unsure and even wrong about '_'.

    1. Capture Patterns: I was confused by 'And is instead...'. 'It is instead ...', where 'it' refers to '_', is clearer to me.

    2. Wildcard Patterns: "'_' is a soft keyword" just says it sometimes is and sometimes is not, but not when, or rather, where. After experiments like this (using the new IDLE 'copy with prompts' option ;-):

    >>> _ = 'a'
    >>> match [_, 'b']:
    ...     case [capture, _] if _ == 'a':
    ...         print(capture, _)
    ... 
    a a

    I added (in PR to come, with markup that might be improved)
    "within any pattern, but only within patterns. It is an identifier, as usual, even within match headers, guards, and case blocks.

    Please consider also adding an example like the above.

    @terryjreedy terryjreedy added 3.10 only security fixes 3.11 only security fixes labels May 4, 2021
    @terryjreedy terryjreedy added docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error 3.10 only security fixes 3.11 only security fixes labels May 4, 2021
    @miss-islington
    Copy link
    Contributor

    New changeset ae4f857 by Miss Islington (bot) in branch '3.10':
    bpo-44025: Clarify when '_' is a keyword. (GH-25873)
    ae4f857

    @terryjreedy
    Copy link
    Member Author

    bedevere-bot malfunctioned. Lukasz merged PR 25873 into main, and I verified the change on the main branch. But the PR is listed above as closed, not merged, and commit 3b200b2 is not listed.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @slateny
    Copy link
    Contributor

    slateny commented Aug 23, 2022

    Since it's merged and the changes shown, then despite it showing as closed in bpo, I'd say this can be considered complete.

    @slateny slateny closed this as completed Aug 23, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes 3.11 only security fixes docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants