Nothing here
Nothing here

Reputation: 2363

Pass named arguments in list comprehensions in map function

I am trying to pass arguments in to a function which is being mapped. Is there a way to clean this up or optimize?

# Map resized images
resized_imgs = tuple(map(resize_image, all_img_steps, [None for img in all_img_steps], [output_height for img in all_img_steps]))

Thanks!

Upvotes: 2

Views: 148

Answers (1)

wjandrea
wjandrea

Reputation: 32954

Use a generator expression instead of a map.

resized_imgs = tuple(resize_image(img, None, output_height) for img in all_img_steps)

Upvotes: 5

Related Questions