简体   繁体   English

在 map 函数的列表推导式中传递命名参数

[英]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!谢谢!

使用生成器表达式而不是映射。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM