我有以下命名的元组:
from collections import namedtuple Product = namedtuple( 'Product','product_symbol entity unique_id as_of_date company_name followers linkedin_employees linkedin industry date_added date_updated description website sector product_industry' )
声明它的最佳方法是什么,所以它不超过80行的Python行限制?
解决方法
我提出了一个PEP-8兼容版本,它将您的属性声明为列表.
name = 'Product' attrs = [ 'product_symbol','entity','unique_id',... ] Product = namedtuple(name,attrs)
将尾随逗号添加到attrs,this makes it easy when doing diff comparisons.