I was reading source code of collections.py yesterday.
In the namedtuple function, a template string is generated and then execed in a temporary namespace.
In the namespace dict, property is renamed to _property and tuple to _tuple.
I wonder what’s the reason behind this. What problems does this renaming helps avoid?
In general, the underscore names are sometimes used in the standard library to to keep a namespace clean.
In the case of _tuple, it was necessary because you’re allowed to use “tuple” as a field name: