I’m using python while some method requires tuple as its argument. Although instance created by namedtuple is tuple subclass, but it seems that I still need to transform it to tuple.
Is there any way to transform the tuple subclass made by namedtuple to tuple quickly? Thanks!
I’m using python while some method requires tuple as its argument. Although instance created
Share
A
namedtupleinstancexcan be converted to a tuple usingtuple(x), but you shouldn’t need to do so. If some code only accepts tuples, but nonamedtuples, I consider that code broken. (There may be special cases that require such a behaviour, but I can’t think of any right now.)