如何在python中拆分长python表达式
我应该如何按照PEP-8指南格式化以下代码?我没有看到这样的例子。还是没有这方面的指导方针?关于SO的大多数问题都是关于拆分长条件或行继续的如何在python中拆分长python表达式,python,syntax,code-formatting,pep8,Python,Syntax,Code Formatting,Pep8,我应该如何按照PEP-8指南格式化以下代码?我没有看到这样的例子。还是没有这方面的指导方针?关于SO的大多数问题都是关于拆分长条件或行继续的 def send_notification(version, device_type): reg_ids = UDR.objects.filter(device_type=device_type).values_list('id', 'device_type', 'registration_id') if not reg_ids:
def send_notification(version, device_type):
reg_ids = UDR.objects.filter(device_type=device_type).values_list('id', 'device_type', 'registration_id')
if not reg_ids:
logger.debug("No notifications to send")
是否应将其格式化为:
def send_notification(version, device_type):
reg_ids = UDR.objects.filter(
device_type=device_type).values_list('id',
'device_type', 'registration_id')
if not reg_ids:
logger.debug("No notifications to send")
或者说:
def send_notification(version, device_type):
reg_ids = UDR.objects.filter(device_type=device_type)\
.values_list('id',
'device_type',
'registration_id')
if not reg_ids:
logger.debug("No notifications to send")
还是别的什么 您可以从以下URL获取一些指导
试一试,如果你不懂,一定要问清楚。如果有人知道,autopep8会帮助你格式化代码,使之符合pep8,并且可以很好地将代码格式化。