[Patches] [ python-Patches-1463370 ] Add .format() method to str and unicode

SourceForge.net noreply at sourceforge.net
Mon Apr 3 20:44:07 CEST 2006


Patches item #1463370, was opened at 2006-04-03 03:42
Message generated for change (Comment added) made by gvanrossum
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1463370&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Core (C code)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: crutcher (crutcher_gmail)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add .format() method to str and unicode

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

----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2006-04-03 14:44

Message:
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.

----------------------------------------------------------------------

Comment By: M.-A. Lemburg (lemburg)
Date: 2006-04-03 04:37

Message:
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__().

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1463370&group_id=5470


More information about the Patches mailing list