A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2010-March/098871.html below:

[Python-Dev] Issue 6081: format string using mapping rather than kwargs

[Python-Dev] Issue 6081: format string using mapping rather than kwargsNick Coghlan ncoghlan at gmail.com
Thu Mar 25 12:00:35 CET 2010
Filip GruszczyƄski wrote:
> I would appreciate any advice on this topic, even if this ticket would
> be dismissed altogether, as I would like to learn as much as possible
> on practices on developing Python.

Raymond's use case is valid, but the currently proposed method name is
way too long to be usable and the use of *args is a definite misfeature.

I suggest approaching the issue with the exact spec needed to cover the
problem Raymond described:

   Add a method to strings that allows a format string to
   be applied to an existing mapping without implicitly
   converting the mapping to a dict first.

>From that spec, a straightforward API falls out:

    def format_mapping(self, kwds):
      # Method body actually written in C, so it can
      # easily invoke the internal formatting operation
      return do_string_format(self, NULL, kwds)

Sure, you can't mix positional and keyword arguments the way you can
with .format(), but you can't mix and match those with mod-formatting
either.

*If* support for a sequence were to be added (and that's a big if), it
should be added as an explicit second argument, not as a *args argument.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4