Why create an empty class and then create it and set some attributes?

html2txt contains the following code:

class Storage: pass
options = Storage()
options.google_doc = False
options.ul_item_mark = '*'

I have not seen such an approach before. What is the use / use of this approach in setting attributes in __init__(), and is it a class even needed here?

+4
source share
2 answers

, . dict, . python . .

+4

, namedtuples .

python docs:

EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title, department, paygrade')
+1

Source: https://habr.com/ru/post/1628236/


All Articles