Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

namedtuple declaration indentation

Tags:

python

I have the following 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'
    )

What is the best way to declare it, so it does not exceeds the Python line limit of 80 characters?

like image 464
gogasca Avatar asked Mar 09 '26 12:03

gogasca


1 Answers

I propose a PEP-8 compliant version which declares your attributes as a list.

name = 'Product'
attrs = [
   'product_symbol',
   'entity',
   'unique_id',
   ... 
]

Product = namedtuple(name, attrs)

Add a trailing comma to attrs, this makes it easy when doing diff comparisons.

like image 85
cs95 Avatar answered Mar 11 '26 02:03

cs95



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!