Reproduce your mistakes
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)
Debug Info
=======================================
# Transition01(1, 2, 3)
# Traceback (most recent call last):
# TypeError: __new__() takes 3 positional arguments but 4 were given
========================================
Technical details you care about
function namedtuple_Transition.Transition.__new__(_cls, one, two)
Analysis: The named tuple class object you created has an internal implementation method new, and the engineer who defines the method takes the method caller object as the first parameter of the method, and this is a more common class method definition form.