[issue6081] str.format_from_mapping()

2010-11-03 Thread Eric Smith
Eric Smith added the comment: Updated patch which adds tests and minimal docs. Named changed to format_map. I'll commit this before 3.2b1 unless I hear a complaint. -- keywords: +easy, needs review resolution: -> accepted Added file: http://bugs.python.org/file19482/issue6081-1.diff

[issue6081] str.format_from_mapping()

2010-09-09 Thread Florent Xicluna
Changes by Florent Xicluna : -- nosy: +flox ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.o

[issue6081] str.format_from_mapping()

2010-08-11 Thread Terry J. Reedy
Terry J. Reedy added the comment: I understand now that new methods, as opposed to changed methods, are allowed. I agree with Eric that this seems more like a convinience rather than absolute necessity, and that the doc should be augmented. The doc for vformat (which I admit I had not noticed

[issue6081] str.format_from_mapping()

2010-08-11 Thread Eric Smith
Eric Smith added the comment: I'll work on cleaning this up for 3.2. Any comments on the name of the method? -- ___ Python tracker ___ __

[issue6081] str.format_from_mapping()

2010-08-11 Thread Raymond Hettinger
Raymond Hettinger added the comment: This can be done for Py3.2. It completes needed functionality for string formatting which is something we all want to take hold and is necessary for the 3.x series to succeed. -- versions: +Python 3.2 -Python 3.3 _

[issue6081] str.format_from_mapping()

2010-08-11 Thread Éric Araujo
Changes by Éric Araujo : -- nosy: +eric.araujo ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pytho

[issue6081] str.format_from_mapping()

2010-08-09 Thread Terry J. Reedy
Terry J. Reedy added the comment: I believe this is covered by the PEP3003 3.2 change moratorium. -- nosy: +terry.reedy versions: +Python 3.3 -Python 2.7, Python 3.2 ___ Python tracker _

[issue6081] str.format_from_mapping()

2010-03-25 Thread Eric Smith
Eric Smith added the comment: It occurs to me that Raymond's use case could be satisfied using existing Python, by slightly changing the format string. After all, str.format() supports mapping lookup already: $ ./python.exe Python 2.6.5+ (release26-maint:79421, Mar 25 2010, 08:51:39) [GCC 4.2

[issue6081] str.format_from_mapping()

2010-03-23 Thread Eric Smith
Eric Smith added the comment: I'm not sure I'm wild about the *args parameter. Calling "Fred" the 0-th parameter here seems non-intuitive: "My name is {0}".format_using_mapping({}, 'Fred') If you're going to have *args, why not **kwargs and then merge/update the dicts? I'm being facetious, b

[issue6081] str.format_from_mapping()

2010-03-23 Thread Filip Gruszczyński
Filip Gruszczyński added the comment: I have created a new patch, that should be satisfying now. There is help (though it is quite small, I tried to mimic those that were already in unicode.c) and tests. Right now format_using_mapping is called like this: format_using_mapping(mapping, *args)

[issue6081] str.format_from_mapping()

2010-03-19 Thread Filip Gruszczyński
Filip Gruszczyński added the comment: Ok, unfortunately this code won't work for certain tests. Take those: self.assertEqual("My name is {0}".format('Fred'), "My name is Fred") We pass only one argument, which is a dict and this won't satisfy such test. We need to think about a differ

[issue6081] str.format_from_mapping()

2010-03-19 Thread Eric Smith
Eric Smith added the comment: http://docs.python.org/library/stdtypes.html#str.format, for starters. This is in Doc/library/stdtypes.rst. For tests, probably in Lib/test/test_unicode.py. I'm not sure if we should add this to 2.7 (or even 3.2, for that matter), but if so, we should start by p

[issue6081] str.format_from_mapping()

2010-03-19 Thread Filip Gruszczyński
Filip Gruszczyński added the comment: Could you point me, where to add tests and documentation? I would happily add those. -- ___ Python tracker ___

[issue6081] str.format_from_mapping()

2010-03-19 Thread Eric Smith
Changes by Eric Smith : Removed file: http://bugs.python.org/file16585/issue6081.diff ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue6081] str.format_from_mapping()

2010-03-19 Thread Eric Smith
Eric Smith added the comment: Added a comment to explain the change. -- Added file: http://bugs.python.org/file16586/issue6081.diff ___ Python tracker ___ ___

[issue6081] str.format_from_mapping()

2010-03-19 Thread Eric Smith
Eric Smith added the comment: I believe this patch fixes the issue. Tests and documentation are still needed, of course. -- Added file: http://bugs.python.org/file16585/issue6081.diff ___ Python tracker __

[issue6081] str.format_from_mapping()

2010-03-18 Thread Filip Gruszczyński
Filip Gruszczyński added the comment: My first intention was simply to push mapping from args to kwargs, just like Eric suggested, but that didn't help with __missing__, only with accepting a dict instead of pushing keyword arguments. I didn't like explicitly asking for __missing__ either, bu

[issue6081] str.format_from_mapping()

2010-03-18 Thread Eric Smith
Eric Smith added the comment: I agree with David. Although it's not clear to my why the code doesn't just work with the addition of do_string_format_using_mapping and without the other code. It's possible the existing code is too dict-specific and should be calling a more generic PyObject in

[issue6081] str.format_from_mapping()

2010-03-18 Thread R. David Murray
R. David Murray added the comment: I don't think this patch satisfies Raymond's request. It is explicitly checking for a __missing__ attribute, but Raymond was talking about a more general facility whereby you can pass in an arbitrary object that implements the mapping interface. Using the

[issue6081] str.format_from_mapping()

2010-03-18 Thread Ezio Melotti
Ezio Melotti added the comment: Thanks for the patch. It would be nice if you could include unit tests too. -- priority: -> normal stage: -> test needed ___ Python tracker ___

[issue6081] str.format_from_mapping()

2010-03-18 Thread Filip Gruszczyński
Filip Gruszczyński added the comment: I have created a small patch, that adds method that formats using a dict. It's the first time I have written anything in python implementation, so I would very appreciate any advice. Change allows the following: >>> m = Mapping(a='b') >>> '{a} {c}'.format

[issue6081] str.format_from_mapping()

2010-03-15 Thread Eric Smith
Changes by Eric Smith : -- assignee: -> eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.

[issue6081] str.format_from_mapping()

2010-03-13 Thread Ezio Melotti
Changes by Ezio Melotti : -- nosy: +ezio.melotti ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.pyt

[issue6081] str.format_from_mapping()

2009-06-01 Thread Evan Behar
Changes by Evan Behar : -- nosy: +ebehar ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/

[issue6081] str.format_from_mapping()

2009-05-27 Thread Eric Smith
Eric Smith added the comment: I think this would be useful. I don't fee terribly strongly about it, but I think I'd like the name str.format_using_mapping(). When I initially saw this, I thought from the name it was creating a format object (whatever that would be) from a mapping object. -

[issue6081] str.format_from_mapping()

2009-05-22 Thread Eric Smith
Changes by Eric Smith : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue6081] str.format_from_mapping()

2009-05-21 Thread Raymond Hettinger
New submission from Raymond Hettinger : The old % formatting allowed arbitrary mappings: >>> class Default(dict): ... def __missing__(self, key): ... return key ... >>> s = '%(name)s was born in %(country)s' >>> s % Default(name='Guido') 'Guido was born in country' But