[Python-Dev] [Python-checkins] r86976 - in python/branches/py3k: Doc/library/configparser.rst Doc/library/fileformats.rst Lib/configparser.py Lib/test/test_cfgparser.py Misc/NEWS

Łukasz Langa lukasz at langa.pl
Fri Dec 3 23:45:33 CET 2010


Wiadomość napisana przez Éric Araujo w dniu 2010-12-03, o godz. 19:35:

> Hello,
> 
>> Author: lukasz.langa
>> New Revision: 86976
>> Log: Issue 10499: Modular interpolation in configparser
>> 
>> Modified: python/branches/py3k/Doc/library/configparser.rst
> Is the module still backward compatible with the 3.1 version, modulo
> fixed bugs?  I haven’t been able to follow closely all the great
> improvements you’ve been making, and there has been a lot of movement in
> the code, so I’m not sure.

There have been minor incompatibilities, all have been thoroughly discussed with Fred and other developers. No changes should cause silent breakage, though.

> Thanks for taking up configparser.  Maybe it will become so useful and
> extensible that you’ll have to release it on PyPI for older Pythons :)

Sure. Why not? :)

>> Modified: python/branches/py3k/Doc/library/fileformats.rst
> This looks like unrelated changes that slipped in the commit. 

As we discussed this on IRC, this is an unfortunate slip caused by me trying to wrap up documentation updates in one go. Will remember to do that separately now. Thanks!

>> Modified: python/branches/py3k/Lib/configparser.py
>> 
>>         Raise DuplicateSectionError if a section by the specified name
>>         already exists. Raise ValueError if name is DEFAULT.
>>         """
>> -        if section == self._default_section:
>> +        if section == self.default_section:
>>             raise ValueError('Invalid section name: %s' % section)
> I think it’s the only error message using %s instead of %r.  The quotes
> added by %r typically help spot names with spaces (embedded or trailing)
> and the like.

Corrected in rev 86999, thanks.

>> +        options = list(d.keys())
>> +        if raw:
>> +            return [(option, d[option])
>> +                    for option in options]
>> +        else:
>> +            return [(option, self._interpolation.before_get(self, section,
>> +                                                            option, d[option],
>> +                                                            d))
>> +                    for option in options]
> The list call seems unneeded.  Minor style point: I avoid such dangling
> arguments that don’t read great, I prefer to go to a newline after the
> opening paren:
>               return [(option, self._interpolation.before_get(
>                   self, section, option, d[option], d)) for
>                   option in options]

You're right that my formatting looks ugly but yours is not that much better either ;) How about:

        value_getter = lambda option: self._interpolation.before_get(self,
            section, option, d[option], d)
        if raw:
            value_getter = lambda option: d[option]
        return [(option, value_getter(option))
                for option in d.keys()]

-- 
Best regards,
Łukasz Langa
tel. +48 791 080 144
WWW http://lukasz.langa.pl/

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20101203/668b63f3/attachment.html>


More information about the Python-Dev mailing list