Воспроизведите ваши ошибки
import collections
# Two-way construct numedtuple
# 1st way:use iterable object as 2nd paras
Transition01 = collections.namedtuple('Transition', ['one', 'two'])
# 2nd way:use space-splited string as 2nd paras
Transition02 = collections.namedtuple('Transition', 'one two')
# In order to figure out the field names contained in a namedtuple object, it is recommended to use the _fields attribute.
print(Transition01._fields)
print(Transition01._fields == Transition02._fields)
# After you know the field name contained in a namedtuple object, it is recommended to initialize the namedtuple using keyword arguments because it is easier to debug than positional parameters.
nttmp01 = Transition01(one=1, two=2)
nttmp02 = Transition01(1, 2)
print(nttmp01)
print(nttmp02)
Отладочная информация
=======================================
# Transition01(1, 2, 3)
# Traceback (most recent call last):
# TypeError: __new__() takes 3 positional arguments but 4 were given
========================================
Технические детали, которые вас интересуют
function namedtuple_Transition.Transition.__new__(_cls, one, two)
Анализ: Созданный вами объект класса именованного кортежа имеет внутренний метод реализации new и инженер, который определяетметод принимает объект вызывающего метода в качестве первого параметра метода, и это более распространенная форма определения метода класса.