On 11/6/10 1:16 AM, Ezio Melotti wrote: >> +.. method:: str.format_map(mapping) >> + >> + Similar to ``str.forrmat(**mapping)``, except that ``mapping`` is >> + used directly and not copied to a :class:`dict` . This is useful >> + if for example ``mapping`` is a dict subclass. > > > Including the "__missing__" example might be better. From the > description, it's not clear why str.format(**dict_subclass) wouldn't > work and that the previous line refers to the fact that ** converts the > mapping in a plain dict, thus making __missing__ and other things unusable. I agree, but I was hesitant to add a long example. But thinking about it some more I think I'll add it. >> + >> + self.assertEqual('{foo._x}'.format_map({'foo': C(20)}), '20') >> + > > > The classes D-H seem unused, did you forget to add some tests or am I > missing something? It was a big copy job from the other tests. I'll review them all. >> +PyDoc_STRVAR(format_map__doc__, >> + "S.format_map(mapping) -> str\n\ >> +\n\ >> +"); >> + > > > Wouldn't a more verbose docstring be better? (str.format seems to lack > one too) Undoubtedly true. Any suggestions? How about (for .format): "Returns S formatted with substitutions from args and kwargs." I also see that __format__'s docstring is similarly terse. Thanks for reviewing! -- Eric.
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