Relevance of typename in namedtuple

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.

Leave a Comment