Re: [Python-ideas] unify usage of mutable and immutable objects

March 1, 2017
2:20 a.m.
What I want are such interfaces (no matter with standard set): class IDynSet: # "Dyn" means it have methods like ipop_both def ipop_both(self): if hasattr(self, 'pop_mutable'): elem = self.pop_mutable() elif hasattr(self, 'ipop_immutable'): elem, self = self.ipop_immutable() else: raise return elem, self class IMutableDynSet(IDynSet): def pop_mutable(self): return self.pop() class IImutableDynSet(IDynSet): def ipop_immutable(self): elem, new = self.ipop() # ipop not pop return elem, new
2940
Age (days ago)
2940
Last active (days ago)
0 comments
1 participants
participants (1)
-
语言破碎处