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 — Add textwrap.dedent, .indent, as str methods. · Issue #62535 · python/cpython

Add textwrap.dedent, .indent, as str methods. #62535

New issue
Copy link
New issue
Copy link
Open
Open
Add textwrap.dedent, .indent, as str methods.#62535
Copy link
Labels
stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-featureA feature request or enhancementA feature request or enhancement

Description

@terryjreedy
terryjreedy
opened on Jul 1, 2013
Issue body actions
BPO 18335
Nosy @warsaw, @terryjreedy, @ncoghlan, @ezio-melotti, @merwok, @Julian, @ericsnowcurrently, @vadmium, @serhiy-storchaka

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 2013-07-01.05:33:49.321>
labels = ['type-feature']
title = 'Add textwrap.dedent, .indent, as str methods.'
updated_at = <Date 2013-09-01.01:58:54.523>
user = 'https://github.com/terryjreedy'

bugs.python.org fields:

activity = <Date 2013-09-01.01:58:54.523>
actor = 'martin.panter'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = []
creation = <Date 2013-07-01.05:33:49.321>
creator = 'terry.reedy'
dependencies = []
files = []
hgrepos = []
issue_num = 18335
keywords = []
message_count = 7.0
messages = ['192109', '192114', '192115', '192116', '192133', '192148', '196696']
nosy_count = 12.0
nosy_names = ['barry', 'terry.reedy', 'ncoghlan', 'ezio.melotti', 'eric.araujo', 'cvrebert', 'Julian', 'tshepang', 'eric.snow', 'martin.panter', 'serhiy.storchaka', 'SpaghettiToastBook']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'patch review'
status = 'open'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue18335'
versions = ['Python 3.4']

Activity

  1. terryjreedy commented on Jul 1, 2013

    @terryjreedy
    terryjreedy
    on Jul 1, 2013
    MemberAuthor
    More actions

    To end proposals for new syntax to do what they do for triple-quoted strings. Nick Coghlan gave reasons as follows: run time cost small, can be optimized away, would be used more than some other string methods.
    http://mail.python.org/pipermail/python-ideas/2013-July/021717.html

    In response, Guido said "That's a compelling argument. Let's do it."
    http://mail.python.org/pipermail/python-ideas/2013-July/021718.html

  2. terryjreedy
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Jul 1, 2013
  3. ncoghlan commented on Jul 1, 2013

    @ncoghlan
    ncoghlan
    on Jul 1, 2013
    Contributor
    More actions

    It turns out there's one slight wrinkle in this grand plan: it won't work for docstrings without some additional tweaking to allow for method calls in the docstring detection.

    >>> def f():
    ...     """example""".lower()
    ... 
    >>> print(f.__doc__)
    None
    >>> import dis
    >>> dis.dis(f)
      2           0 LOAD_CONST               1 ('example') 
                  3 LOAD_ATTR                0 (lower) 
                  6 CALL_FUNCTION            0 (0 positional, 0 keyword pair) 
                  9 POP_TOP              
                 10 LOAD_CONST               0 (None) 
                 13 RETURN_VALUE
  4. ncoghlan commented on Jul 1, 2013

    @ncoghlan
    ncoghlan
    on Jul 1, 2013
    Contributor
    More actions

    I still think the methods are worth adding regardless - I just anticipate a request to allow method calls on docstrings to follow not long after ;)

  5. serhiy-storchaka commented on Jul 1, 2013

    @serhiy-storchaka
    serhiy-storchaka
    on Jul 1, 2013
    Member
    More actions

    str already have too many methods. Who uses str.swapcase() or str.zfill() now? I'm -0.5 for adding any new str methods.

  6. warsaw commented on Jul 1, 2013

    @warsaw
    warsaw
    on Jul 1, 2013
    Member
    More actions

    .dedent() is a no-brainer. JFDI. +1

    .indent() I guess makes sense for symmetry, although I've rarely used it. -0

    As for docstrings, I can imagine other alternatives, so let's let someone interested in that go through the PEP process.

  7. merwok commented on Jul 1, 2013

    @merwok
    merwok
    on Jul 1, 2013
    Member
    More actions

    IMO it’s fine that docstrings continue to live as pure string literals, and documentation tools continue to follow PEP-257’s advice.

  8. vadmium commented on Sep 1, 2013

    @vadmium
    vadmium
    on Sep 1, 2013
    Member
    More actions

    If this goes ahead, would a bytes.dedent() method be also considered? I recently discovered that textwrap.dedent() does not work on bytes() in Python 3. I would have used it for the contents of an input file in a test case.

    For the record there’s an older bpo-1237680 on this, rejected in 2005.

  9. ezio-melotti
    transferred this issue fromon Apr 10, 2022
  10. methane commented on Jul 1, 2023

    @methane
    methane
    on Jul 1, 2023
    Member
    More actions

    #81087 is a relating issue.

  11. methane commented on Jul 14, 2023

    @methane
    methane
    on Jul 14, 2023
    Member
    More actions

    I implemented compile time cleandoc in #106411.
    So this issue should be focus on str.dedent() and bytes.dedent().

    textwrap.dedent() is complex function. I want to make str.dedent() much simpler.

    • remove only whitespace -- user need to use textwrap.dedent() to support TAB indent
      • If we want to support TAB, we will add option later.
    • both of bytes.dedent() and str.dedent() use same char* based logic -- str.dedent() uses utf-8. This minimize our maintenance cost.
  12. methane commented on Jul 23, 2023

    @methane
    methane
    on Jul 23, 2023
    Member
    More actions

    I created a poll on discuss.python.org for naming.
    https://discuss.python.org/t/str-dedent-vs-str-removeindent/30127

  13. iritkatriel
    added
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    on Nov 27, 2023
  14. ofek commented on Dec 9, 2023

    @ofek
    ofek
    on Dec 9, 2023
    SponsorContributor
    More actions

    What is the status of this?

  15. methane commented on Dec 10, 2023

    @methane
    methane
    on Dec 10, 2023
    Member
    More actions

    I need to write a PEP for this. But I don't have time for it for now.

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

    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-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.