if head:
s.append(head)
- i = 0
- for key in sorted(self.values):
+ for i, key in enumerate(sorted(self.values)):
if i:
s.append(", ")
- i += 1
s.append(key.to_string())
if self.type.is_map():
s += ["%s->keys = xmalloc(%d * sizeof *%s->keys);"
% (var, len(self.values), var)]
- i = 0
- for key, value in sorted(self.values.items()):
+ for i, key in enumerate(sorted(self.values)):
s += key.cInitAtom("%s->keys[%d]" % (var, i))
- i += 1
if self.type.value:
s += ["%s->values = xmalloc(%d * sizeof *%s->values);"
% (var, len(self.values), var)]
- i = 0
- for key, value in sorted(self.values.items()):
+ for i, (key, value) in enumerate(sorted(self.values.items())):
s += value.cInitAtom("%s->values[%d]" % (var, i))
- i += 1
else:
s += ["%s->values = NULL;" % var]
items = sorted(obj.items())
else:
items = obj.iteritems()
- i = 0
- for key, value in items:
+ for i, (key, value) in enumerate(items):
if i > 0:
stream.write(u",")
- i += 1
__dump_string(stream, unicode(key))
stream.write(u":")
to_stream(value, stream, pretty, sort_keys)
stream.write(u"}")
elif type(obj) in (list, tuple):
stream.write(u"[")
- i = 0
- for value in obj:
+ for i, value in enumerate(obj):
if i > 0:
stream.write(u",")
- i += 1
to_stream(value, stream, pretty, sort_keys)
stream.write(u"]")
else: