This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Ross Biro
Recipients Ross Biro
Date 2019-03-01.18:00:37
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1551463237.42.0.662245603884.issue36159@roundup.psfhosted.org>
In-reply-to
Content
The only point in the string.Formatter class that really depends on string output is line 245: return ''.join(result), auto_arg_index.  

I'm currently working on a problem that would be much easier if I could get access to the result list instead of having that join called.

I propose creating another overridable method in string.Formatter, say oformat that calls _vformat and is called by vformat. oformat would have the guts of vformat and just return the result list.  vformat would then consist of the call ot oformat and the join.  See Below.  The recursive call to _vformat would also need some slight modification.

The work would not be difficult and I'm willing to do it, provided there is sufficient interest.

def vformat(self, format_string, args, kwargs):
        result = self.oformat(format_string, args, kwargs)
	return ''.join(result)

def oformat(self, format_string, args, kwargs):
        used_args = set()
        result, _ = self._vformat(format_string, args, kwargs, used_args, 2)
        self.check_unused_args(used_args, args, kwargs)
        return result
History
Date User Action Args
2019-03-01 18:00:37Ross Birosetrecipients: + Ross Biro
2019-03-01 18:00:37Ross Birosetmessageid: <1551463237.42.0.662245603884.issue36159@roundup.psfhosted.org>
2019-03-01 18:00:37Ross Birolinkissue36159 messages
2019-03-01 18:00:37Ross Birocreate