edgegraph.structure.singleton.drop_semi_singleton_mapping#
- edgegraph.structure.singleton.drop_semi_singleton_mapping(cls, *args, **kwargs)#
Remove an mapping from the specified semi-singleton instance.
This removes a single mapping of a key to instance. It may be considered removing a semisingleton instance, though if multiple mappings exist to single instance, it will still be accessible by other remaining identifiers.
See also
clear_semi_singleton(), a clear-all operation instead of this clear-one
>>> from edgegraph.singleton import semi_singleton_metaclass, \ drop_semi_singleton_mapping >>> class SemiSingleton(metaclass=semi_singleton_metaclass()): ... def __init__(self, foo, bar=False): ... self.foo = foo ... self.bar = bar ... >>> s3 = SemiSingleton(37, True) # different arguments -- different object >>> s3 <__main__.SemiSingleton object at 0x01234567> >>> s4 = SemiSingleton(4) >>> s5 = SemiSingleton(5) >>> drop_semi_singleton_mapping(SemiSingleton, 4) # drop s4 >>> s4_2 = SemiSingleton(4) # will now return a new instance >>> s4 is s4_2 False >>> SemiSingleton(5) is s5 # other mappings unaffected True
- Parameters:
cls (type) – Class to remove the mapping from. This is typically thought of as
type(some_object).*args – Positional arguments as would normally be passed to the semi-singleton class instantiation.
**kwargs – Positional arguments as would normally be passed to the semi-singleton class instantiation.