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

Add .format() method to str and unicode #43150

Closed
crutchergmail mannequin opened this issue Apr 3, 2006 · 5 comments
Closed

Add .format() method to str and unicode #43150

crutchergmail mannequin opened this issue Apr 3, 2006 · 5 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@crutchergmail
Copy link
Mannequin

crutchergmail mannequin commented Apr 3, 2006

BPO 1463370
Nosy @malemburg, @gvanrossum
Files
  • format.diff: patch to add .format() to str and unicode
  • 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 = <Date 2008-01-06.22:29:46.687>
    created_at = <Date 2006-04-03.07:42:31.000>
    labels = ['interpreter-core']
    title = 'Add .format() method to str and unicode'
    updated_at = <Date 2008-01-06.22:29:46.687>
    user = 'https://bugs.python.org/crutchergmail'

    bugs.python.org fields:

    activity = <Date 2008-01-06.22:29:46.687>
    actor = 'admin'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2006-04-03.07:42:31.000>
    creator = 'crutcher_gmail'
    dependencies = []
    files = ['7138']
    hgrepos = []
    issue_num = 1463370
    keywords = ['patch']
    message_count = 5.0
    messages = ['49949', '49950', '49951', '49952', '49953']
    nosy_count = 3.0
    nosy_names = ['lemburg', 'gvanrossum', 'crutcher_gmail']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1463370'
    versions = ['Python 3.0']

    @crutchergmail
    Copy link
    Mannequin Author

    crutchergmail mannequin commented Apr 3, 2006

    patch to add .format() method to string and unicode types.

    @crutchergmail crutchergmail mannequin closed this as completed Apr 3, 2006
    @crutchergmail crutchergmail mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Apr 3, 2006
    @crutchergmail crutchergmail mannequin closed this as completed Apr 3, 2006
    @crutchergmail crutchergmail mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Apr 3, 2006
    @malemburg
    Copy link
    Member

    Logged In: YES
    user_id=38388

    Why would we need a method for formatting ? We already have
    the %-based formatting which can also be access via .__mod__().

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    I like this.

    The reason to like this in favor of s%x was expressed by
    Walter Dörwald on the python-3000 list:

    """
    it avoids one problem you might run into with %:
    If you have only one argument, writing s % (x,)
    as s % x will break when the
    argument x happens to be a tuple.
    You won't have this problem with
    s.format(x).
    """

    However, this might be our chance to introduce a new
    formatting syntax, since there are many problems with the %s
    style (especially %(foo)s). See PEP-292.

    We need a Python 3000 group in the trackers.

    @malemburg
    Copy link
    Member

    Logged In: YES
    user_id=38388

    I would rather like to see any non-trivial formatting be
    moved into a module and have functions that operate on
    strings and Unicode.

    Methods on simple types shouldn't really implement any
    complicated features.

    Formatting is one of those things that everybody wants to
    implement in different ways. Just look at the gazillion
    different templating engines out there for examples :-)

    Better remove the %-formatting altogether in Py3k and add a
    module which implements 2.x style %-formatting as well as
    PEP-292 style $-formatting.

    @gvanrossum
    Copy link
    Member

    Logged In: YES
    user_id=6380

    Let's please continue this discussion on
    python-3000@python.org instead of a random SF item.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants