2024-09-29 23:18:48 发布
网友
我的问题是,制作以下代码行最传统的方法是什么:
self.steps = [setpoint_and_hold_time.setpoint for setpoint_and_hold_time in program.setpoints_and_hold_times]
到79个字符或更少的列?你知道吗
另外,我假设这行代码不需要太多背景上下文,如果需要,请告诉我,我将在一些类中编辑解释这行代码。你知道吗
谢谢。你知道吗
/耸耸肩
由于循环变量的作用域有限,因此不需要给循环变量取长名称。我会缩短setpoint_and_hold_time。你知道吗
setpoint_and_hold_time
self.steps = [sh.setpoint for sh in program.setpoints_and_hold_times]
black将重新格式化为(符合PEP8,我认为它非常可读):
self.steps = [ setpoint_and_hold_time.setpoint for setpoint_and_hold_time in program.setpoints_and_hold_times ]
/耸耸肩
由于循环变量的作用域有限,因此不需要给循环变量取长名称。我会缩短
setpoint_and_hold_time
。你知道吗black将重新格式化为(符合PEP8,我认为它非常可读):
相关问题 更多 >
编程相关推荐