mirror of
https://github.com/erg-lang/erg.git
synced 2025-09-29 04:24:43 +00:00
18 lines
519 B
Python
18 lines
519 B
Python
class Dict(dict):
|
|
def concat(self, other):
|
|
return Dict({**self, **other})
|
|
def diff(self, other):
|
|
return Dict({k: v for k, v in self.items() if k not in other})
|
|
# other: Iterable
|
|
def extend(self, other):
|
|
self.update(other)
|
|
# other: Dict
|
|
def merge(self, other):
|
|
self.update(other)
|
|
def insert(self, key, value):
|
|
self[key] = value
|
|
def remove(self, key):
|
|
res = self.get(key)
|
|
if res != None:
|
|
del self[key]
|
|
return res
|