siple for in expression

alex23 wuwei23 at gmail.com
Wed Mar 4 03:31:40 CET 2009


On Mar 4, 2:05 am, "Matko" <IvaStipan... at inet.hr> wrote:
> Can someone help me to understand the following code:
> uv_face_mapping = [[0,0,0,0] for f in faces]

As others have mentioned, this is a list comprehension, which is a
simpler way of writing the following:

  uv_face_mapping = []
  for f in faces:
    uv_face_mapping.append([0,0,0,0])

Which seems to be setting a default uv_face_mapping for each element
in faces :)




More information about the Python-list mailing list