use dict comprehension where possible

This commit is contained in:
Campbell Barton
2010-07-15 00:52:26 +00:00
parent 4242baa704
commit 7f083c45be
4 changed files with 6 additions and 6 deletions

View File

@@ -360,7 +360,7 @@ def process_next_chunk(file, previous_chunk, importedObjects, IMAGE_SEARCH):
vertMappingIndex = 0
vertsToUse = [i for i in range(len(myContextMesh_vertls)) if faceVertUsers[i]]
myVertMapping = dict( [ (ii, i) for i, ii in enumerate(vertsToUse) ] )
myVertMapping = {ii: i for i, ii in enumerate(vertsToUse)}
tempName= '%s_%s' % (contextObName, matName) # matName may be None.
bmesh = bpy.data.meshes.new(tempName)

View File

@@ -596,7 +596,7 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l
if unique_smooth_groups:
sharp_edges= {}
smooth_group_users= dict([ (context_smooth_group, {}) for context_smooth_group in list(unique_smooth_groups.keys()) ])
smooth_group_users = {context_smooth_group: {} for context_smooth_group in list(unique_smooth_groups.keys())}
context_smooth_group_old= -1
# Split fgons into tri's
@@ -691,7 +691,7 @@ def create_mesh(scn, new_objects, has_ngons, CREATE_FGONS, CREATE_EDGES, verts_l
# map the material names to an index
material_mapping= dict([(name, i) for i, name in enumerate(unique_materials)]) # enumerate over unique_materials keys()
material_mapping = {name: i for i, name in enumerate(unique_materials)} # enumerate over unique_materials keys()
materials= [None] * len(unique_materials)

View File

@@ -444,7 +444,7 @@ class Mesh(bpy_types.ID):
if not hasattr(edges, "pop"):
edges = edges[:]
edge_dict = dict((ed.key, ed) for ed in self.edges if ed.selected)
edge_dict = {ed.key: ed for ed in self.edges if ed.selected}
while edges:
current_edge = edges.pop()

View File

@@ -65,9 +65,9 @@ def extend(obj, operator, EXTEND_MODE):
# vertex index is the key, uv is the value
uvs_vhash_source = dict([(vindex, uvs_source[i]) for i, vindex in enumerate(vidx_source)])
uvs_vhash_source = {vindex: uvs_source[i] for i, vindex in enumerate(vidx_source)}
uvs_vhash_target = dict([(vindex, uvs_target[i]) for i, vindex in enumerate(vidx_target)])
uvs_vhash_target = {vindex: uvs_target[i] for i, vindex in enumerate(vidx_target)}
edge_idxs_source = face_edge_vs(vidx_source)
edge_idxs_target = face_edge_vs(vidx_target)