Hi All, There is a consistency problem between the RawConfigParser and the ConfigParser and SafeConfigParser with the items method. In the first case a list of tuples is returned and in the second two a generator is returned. This is quite confusing and I thought that this was a bug, but the docs indicate that this is what is supposed to happen. An items method that returned a list of tuples as it does in the RawconfigParser would be a useful method to have for both ConfigParser and SafeConfigParser. The RawConfigParser docs say that items should return a list: items( section) Return a list of (name, value) pairs for each option in the given section. The ConfigParser docs say that items should return a generator: items( section[, raw[, vars]]) Create a generator which will return a tuple (name, value) for each option in the given section. Optional arguments have the same meaning as for the get() method. New in version 2.3. RawConfigParser returns list: >>> Config.config <ConfigParser.RawConfigParser instance at 0x00E0DAD0> >>> Config.config.items("personal") [('age', '21'), ('company', 'Aztec'), ('name', 'karthik')] >>> ConfigParser and SafeConfigParser return generator: >>> Config.config <ConfigParser.SafeConfigParser instance at 0x00DB1738> >>> Config.config.items("personal") <generator object at 0x00DC3350> >>> for item in Config.config.items("personal"): ... print item ... ('age', '21') ('company', 'Aztec') ('name', 'karthik') >>> Config.config <ConfigParser.ConfigParser instance at 0x00E0D378> >>> Config.config.items("personal") <generator object at 0x00DB1738> >>> for item in Config.config.items("personal"): ... print item ... ('age', '21') ('company', 'Aztec') ('name', 'karthik') It doesn't make sense to me that the same method should return different objects. Maybe another name for ConfigParser and SafeConfigParser would be appropriate to indicate that a generator was being returned. Regards, Gordon Williams
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