Use built-in functions to replace for loops:

Old code:

for x in y:
  f(x)

New Code:

map(f, y)

Also use defaultdict instead of simple dict when advantageous and use list comprehensions
instead of for loops where map() could be used but requires lambdas.


svn: r14135
This commit is contained in:
Gerald Britton
2010-01-25 17:45:21 +00:00
parent fbb8fa2a52
commit 8f0582df8a
49 changed files with 125 additions and 188 deletions

View File

@ -681,8 +681,7 @@ class GtkDocTable(GtkDocBaseElement):
new_table = GtkDocTable(self._style)
#add the split row
new_table.add_child(r2)
for row in self._children[row_index+1:]:
new_table.add_child(row)
map(new_table.add_child, self._children[row_index+1:])
del self._children[row_index+1:]
return (self, new_table), table_height
@ -1253,9 +1252,8 @@ class CairoDoc(BaseDoc, TextDoc, DrawDoc):
# we need to remember the column width list from the table style.
# this is an ugly hack, but got no better idea.
self._active_row_style = []
for i in range(style.get_columns()):
self._active_row_style.append(style.get_column_width(i))
self._active_row_style = map(style.get_column_width,
range(style.get_columns()))
def end_table(self):
self._active_element = self._active_element.get_parent()