namedtuple()
is a factory function for tuple
subclasses. Here, 'whatsmypurpose'
is the type name. When you create a named tuple, a class with this name (whatsmypurpose
) gets created internally.
You can notice this by using the verbose argument like:
Point=namedtuple('whatsmypurpose',['x','y'], verbose=True)
Also you can try type(p)
to verify this.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…