[Patches] [ python-Patches-1281573 ] String formatting character for str.join

SourceForge.net noreply at sourceforge.net
Sun Sep 4 13:53:46 CEST 2005


Patches item #1281573, was opened at 2005-09-04 21:40
Message generated for change (Comment added) made by ncoghlan
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1281573&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: Nick Coghlan (ncoghlan)
Assigned to: Nobody/Anonymous (nobody)
Summary: String formatting character for str.join

Initial Comment:
Current string formatting doesn't provide an easy way
to say "put the contents of this sequence here, using
this string as the separator".

The only generic way is to use the '%s' formatting
character, and then put "sep.join(map(str, seq))" in
the appropriate place.

This isn't so obvious with lists and tuples, as their
default string representations are usually good enough.
When trying to add debug statements for iterators,
however, the current behaviour is a pain.

This patch adds a '%j' (for 'join) formatting character
that allows a separator string to be specified between
the percent symbol and the format character. For
example, "%'\n'j" would indicate that a newline should
be used to separate items in the supplied iterable.

At this point (initial posting) the patch doesn't
support Unicode objects, and doesn't have any tests or
documentation - it is solely a proof of concept.

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

>Comment By: Nick Coghlan (ncoghlan)
Date: 2005-09-04 21:53

Message:
Logged In: YES 
user_id=1038590

Hmm, looks like this version has a few problems dealing with
generators, so avoid it unless you don't mind the odd seg
fault. . .

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

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


More information about the Patches mailing list