Repository: ManimCommunity/manim

Issue:
VGroup and VDict should implement `del`
`del vgroup[0]` or `del vdict['key']` should just call `.remove()` on the appropriate elements


Discussion:
Sorry if i'm missing something, but what if one wants to remove an element from a VDict and not from the Scene ? Are you talking of `scene.remove ?`
```
class VDict():
def __del__(self, key):
    self.remove(key)
```
Similar: Implementing `in` for a `VDict` to check if key is in `vdict` (and similarly for a VGroup). To make `VDict` as close as possible to python dict, it would be great to support the methods listed [here](https://www.w3schools.com/python/python_ref_dictionary.asp). Maybe "VDict 2.0" after attrs is merged?
Agreed. But also, `Container` should implement `in`...
Also, the easiest way of doing this is to have VDict inherit from `collections.abc.Mapping` or `collections.abc.MutableMapping`

Resolving patch:
diff --git a/manim/mobject/types/vectorized_mobject.py b/manim/mobject/types/vectorized_mobject.py
--- a/manim/mobject/types/vectorized_mobject.py
+++ b/manim/mobject/types/vectorized_mobject.py
@@ -1146,7 +1146,7 @@ def remove(self, key):
 
         Parameters
         ----------
-        key : Hashable
+        key : :class:`typing.Hashable`
             The key of the submoject to be removed.
 
         Returns
@@ -1167,11 +1167,11 @@ def remove(self, key):
         return self
 
     def __getitem__(self, key):
-        """Overriding the [] operator for getting submobject by key
+        """Override the [] operator for item retrieval.
 
         Parameters
         ----------
-        key : Hashable
+        key : :class:`typing.Hashable`
            The key of the submoject to be accessed
 
         Returns
@@ -1189,11 +1189,11 @@ def __getitem__(self, key):
         return submob
 
     def __setitem__(self, key, value):
-        """Overriding the [] operator for assigning submobject like a python dict
+        """Override the [] operator for item assignment.
 
         Parameters
         ----------
-        key : Hashable
+        key : :class:`typing.Hashable`
             The key of the submoject to be assigned
         value : :class:`VMobject`
             The submobject to bind the key to
@@ -1213,6 +1213,62 @@ def __setitem__(self, key, value):
             self.remove(key)
         self.add([(key, value)])
 
+    def __delitem__(self, key):
+        """Override the del operator for deleting an item.
+
+        Parameters
+        ----------
+        key : :class:`typing.Hashable`
+            The key of the submoject to be deleted
+
+        Returns
+        -------
+        None
+
+        Examples
+        --------
+        ::
+
+            >>> from manim import *
+            >>> my_dict = VDict({'sq': Square()})
+            >>> 'sq' in my_dict
+            True
+            >>> del my_dict['sq']
+            >>> 'sq' in my_dict
+            False
+
+        Notes
+        -----
+        Removing an item from a VDict does not remove that item from any Scene
+        that the VDict is part of.
+
+        """
+        del self.submob_dict[key]
+
+    def __contains__(self, key):
+        """Override the in operator.
+
+        Parameters
+        ----------
+        key : :class:`typing.Hashable`
+            The key to check membership of.
+
+        Returns
+        -------
+        :class:`bool`
+
+        Examples
+        --------
+        ::
+
+            >>> from manim import *
+            >>> my_dict = VDict({'sq': Square()})
+            >>> 'sq' in my_dict
+            True
+
+        """
+        return key in self.submob_dict
+
     def get_all_submobjects(self):
         """To get all the submobjects associated with a particular :class:`VDict` object
 
@@ -1237,7 +1293,7 @@ def add_key_value_pair(self, key, value):
 
         Parameters
         ----------
-        key : Hashable
+        key : :class:`typing.Hashable`
             The key of the submobject to be added.
         value : :class:`~.VMobject`
             The mobject associated with the key


Test patch: