--- Lib/string.py 2012-02-17 09:47:29.682536857 +0530 +++ Lib/string.py 2012-02-17 09:47:29.682536857 +0530 @@ -188,6 +188,9 @@ def _vformat(self, format_string, args, kwargs, used_args, recursion_depth): if recursion_depth < 0: raise ValueError('Max string recursion exceeded') + auto_field_count = 0 + # manual numbering + manual = None result = [] for literal_text, field_name, format_spec, conversion in \ self.parse(format_string): @@ -200,7 +203,21 @@ if field_name is not None: # this is some markup, find the object and do # the formatting - + + # automatic numbering + if field_name == "": + if manual: + raise ValueError("cannot switch from manual field specification to automatic field numbering") + manual = False + field_name = str(auto_field_count) + auto_field_count += 1 + + # manual numbering + else: + if manual is False: + raise ValueError("cannot switch from automatic field numbering to manual field specification") + manual = True + # given the field_name, find the object it references # and the argument it came from obj, arg_used = self.get_field(field_name, args, kwargs)