Skip to content

string.Template not flexible enough to subclass (regexes) #41966

Closed

Description

@ianbicking
mannequin
BPO 1198569
Nosy @warsaw, @devdanzin
PRs
  • bpo-1198569: Allow string.Template braced pattern to be different #3288
  • What's New for bpo-1198569 #3303
  • 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 = 'https://github.com/warsaw'
    closed_at = <Date 2017-09-04.20:33:00.449>
    created_at = <Date 2005-05-09.20:55:25.000>
    labels = ['3.7', 'type-feature', 'library']
    title = 'string.Template not flexible enough to subclass (regexes)'
    updated_at = <Date 2017-09-04.21:29:28.993>
    user = 'https://bugs.python.org/ianbicking'

    bugs.python.org fields:

    activity = <Date 2017-09-04.21:29:28.993>
    actor = 'barry'
    assignee = 'barry'
    closed = True
    closed_date = <Date 2017-09-04.20:33:00.449>
    closer = 'barry'
    components = ['Library (Lib)']
    creation = <Date 2005-05-09.20:55:25.000>
    creator = 'ianbicking'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 1198569
    keywords = []
    message_count = 7.0
    messages = ['54520', '82198', '202569', '301226', '301249', '301256', '301267']
    nosy_count = 3.0
    nosy_names = ['barry', 'ianbicking', 'ajaksu2']
    pr_nums = ['3288', '3303']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue1198569'
    versions = ['Python 3.7']

    Activity

    1. ianbicking commented on May 9, 2005

      ianbickingmannequin
      MannequinAuthor

      The regular expressions in string.Template can be
      overidden, but there's not an easy way to override the
      expression for variables inside braces and to a
      different expression than variables not in braces.
      E.g., you might allow full expressions in braces
      (including arbitrary punctuation), but only normal
      variable names outside. An example of using this kind
      of technique:

      http://svn.colorstudy.com/home/ianb/recipes/sub_expr.py

      So, in summary, idpattern should be split into two,
      idpattern and bracepattern. (Maybe a default of None
      for bracepattern, and use idpattern if bracepattern is
      None -- this would be backward compatible so that
      overriding only idpattern will effect both)

    2. added
      stdlib
      type-feature
      on May 9, 2005
    3. devdanzin commented on Feb 16, 2009

      devdanzinmannequin
      Mannequin

      IIUC, Ian's link has a doctest for this feature.

    4. warsaw commented on Nov 10, 2013

      @warsaw
      Member

      This seems like a reasonable request. Do you care to submit a patch with tests and doc updates?

    5. warsaw commented on Sep 4, 2017

      @warsaw
      Member

      Sorry for the long delay. It looks like Ian's original link is no longer valid. Do you have an updated link to a possible doctest or example?

    6. warsaw commented on Sep 4, 2017

      @warsaw
      Member

      Never mind; I crafted a decent test for the PR.

    7. warsaw commented on Sep 4, 2017

      @warsaw
      Member

      New changeset ba42796 by Barry Warsaw in branch 'master':
      bpo-1198569: Allow string.Template braced pattern to be different (bpo-3288)
      ba42796

    8. warsaw commented on Sep 4, 2017

      @warsaw
      Member

      New changeset 973b901 by Barry Warsaw in branch 'master':
      What's New for bpo-1198569 (bpo-3303)
      973b901

    9. transferred this issue fromon Apr 9, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    3.7 (EOL)stdlibtype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions