Apr-06-2019, 11:42 PM
i am wanting to make an expression (method call?) that given a dictionary (or set or frozenset), and a hashable value, makes a shallow copy of the dictionary (or set or frozenset) without the item having a key of the hashable value, if one exists in the original unchanged dictionary (or set or frozenset). i only need to do this with a dictionary but i can see potential equivalency for a set or frozenset. at first i wrote
this is another example where if we could add methods to existing builtin classes like dict, it would be an easier solution.
could this be done as a dictionary view? my use case may be able to use that.
d.copy().some_method()
but i could not find a method that returned a reference to the dictionary, much less delete an item. i need to do separate steps for this (maybe in a function). the cases i have are difficult to either do separate steps or def a function.this is another example where if we could add methods to existing builtin classes like dict, it would be an easier solution.
could this be done as a dictionary view? my use case may be able to use that.