Skip to content

Add parameter @case_sensitive to glob and rglob in pathlib #81079

Description

@ChuangMen
mannequin
BPO 36898
Nosy @serhiy-storchaka
PRs
  • bpo-36898: Add parameter @case_sensitive to glob and rglob in pathlib #13274
  • Files
  • pathlib.py
  • 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 2019-05-13.07:17:56.195>
    labels = ['3.8', 'type-feature', 'library']
    title = 'Add parameter @case_sensitive to glob and rglob in pathlib'
    updated_at = <Date 2019-05-13.07:58:11.844>
    user = 'https://bugs.python.org/ChuangMen'

    bugs.python.org fields:

    activity = <Date 2019-05-13.07:58:11.844>
    actor = 'Chuang Men'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2019-05-13.07:17:56.195>
    creator = 'Chuang Men'
    dependencies = []
    files = ['48328']
    hgrepos = []
    issue_num = 36898
    keywords = []
    message_count = 3.0
    messages = ['342284', '342287', '342289']
    nosy_count = 2.0
    nosy_names = ['serhiy.storchaka', 'Chuang Men']
    pr_nums = ['13274']
    priority = 'normal'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue36898'
    versions = ['Python 3.8']

    Linked PRs

    Activity

    1. ChuangMen commented on May 13, 2019

      ChuangMenmannequin
      MannequinAuthor

      In pathlib, I add a parameter @case_sensitive to glob and rglob.

      Sometimes the extension would be in upper case but sometimes it would be lower case, for example: *.tif and *.TIF. So the parameter @case_sensitive may be useful in some cases.

      Usage example:
      In [1]: from pathlib import Path

      In [2]: path = Path('.')

      In [3]: for each_file in path.glob('*.tif'):
      ...: print(each_file)
      ...:
      a.tif
      b.tif

      In [4]: for each_file in path.rglob('*.TIF'):
      ...: print(each_file)
      ...:
      c.TIF
      TEST/d.TIF

      In [5]: for each_file in path.glob('*.TIF', case_sensitive=False):
      ...: print(each_file)
      ...:
      a.tif
      c.TIF
      b.tif

      In [6]: for each_file in path.rglob('*.TIF', case_sensitive=False):
      ...: print(each_file)
      ...:
      a.tif
      c.TIF
      b.tif
      TEST/d.TIF
      TEST/e.tif

    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      type-featureA feature request or enhancement
      on May 13, 2019
    3. serhiy-storchaka commented on May 13, 2019

      @serhiy-storchaka
      Member

      You can use the pattern '*.[Tt][Ii][Ff]'.

    4. ChuangMen commented on May 13, 2019

      ChuangMenmannequin
      MannequinAuthor

      It is a good solution but when pattern is long, it might be a little inconvenient.
      Anyway, just an advice. Thank you for your reply!

    5. transferred this issue fromon Apr 10, 2022
    6. added a commit that references this issue on Mar 12, 2023
    7. barneygale commented on Mar 12, 2023

      @barneygale
      Contributor

      This should be straightforward to add once #102616 lands.

    8. added a commit that references this issue on Mar 15, 2023
    9. barneygale commented on Mar 15, 2023

      @barneygale
      Contributor

      PR available: #102710

    10. added 2 commits that reference this issue on Mar 22, 2023
    11. added 6 commits that reference this issue on Apr 29, 2023
    12. barneygale commented on May 4, 2023

      @barneygale
      Contributor

      Implemented in 3.12: #102710 / 8100be5

    13. added a commit that references this issue on May 5, 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.8 (EOL)end of lifestdlibStandard Library Python modules in the Lib/ directorytopic-pathlibtype-featureA feature request or enhancement

      Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions