python – namedtuple声明缩进

我有以下命名的元组

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.

相关文章

功能概要:(目前已实现功能)公共展示部分:1.网站首页展示...
大体上把Python中的数据类型分为如下几类: Number(数字) ...
开发之前第一步,就是构造整个的项目结构。这就好比作一幅画...
源码编译方式安装Apache首先下载Apache源码压缩包,地址为ht...
前面说完了此项目的创建及数据模型设计的过程。如果未看过,...
python中常用的写爬虫的库有urllib2、requests,对于大多数比...