3 ms·
NamedTuple has a _replace method (that you probably shouldn't be using) that you could use to build something like that if you really need it.
by dagw 8y ago
NamedTuple has a _replace method (that you probably shouldn't be using) that you could use to build something like that if you really need it.
- js2 8y agoThe _replace method returns a new tuple. The existing tuple is not changed. There's no reason not to use that method. It's part of namedtuple's formal API. The reason for the underscore is so that the method name won't collide with a field. (All of namedtuple's methods use a leading underscore.)