How to check immutability [duplicate]
问题 This question already has answers here : Check for mutability in Python? (6 answers) Closed 6 years ago . In python, is there any way to check if an object is immutable or mutable? like isimmutable(a) would return True , if a is immutable, else returns False . 回答1: There are no general tests for immutability. An object is immutable only if none of its methods can mutate the underlying data. take a look at this question the answer says: 1) Keys must not be mutable, unless you have a user