Skip to content

Commit b711ec5

Browse files
authored
Merge pull request #499 from nilaybhatia/vgroup-vdict-printable
Make VGroup and VDict printable
2 parents 037c9be + 829c655 commit b711ec5

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

docs/source/changelog.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Mobjects, Scenes, and Animations
6060
#. The :code:`Container` class has been made into an AbstractBaseClass, i.e. in cannot be instantiated. Instead, use one of its children classes
6161
#. The ``TextMobject`` and ``TexMobject`` objects have been deprecated, due to their confusing names, in favour of ``Tex`` and ``MathTex``. You can still, however, continue to use ``TextMobject`` and ``TexMobject``, albeit with Deprecation Warnings constantly reminding you to switch.
6262
#. Add a :code:`Variable` class for displaying text that continuously updates to reflect the value of a python variable.
63-
63+
#. :code:`VGroup` now supports printing the class names of contained mobjects and :code:`VDict` supports printing the internal dict of mobjects
6464

6565

6666
Documentation

manim/mobject/mobject.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(self, **kwargs):
6262
self.generate_points()
6363
self.init_colors()
6464

65-
def __str__(self):
65+
def __repr__(self):
6666
return str(self.name)
6767

6868
def reset_points(self):

manim/mobject/types/vectorized_mobject.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,14 @@ def __init__(self, *vmobjects, **kwargs):
876876
VMobject.__init__(self, **kwargs)
877877
self.add(*vmobjects)
878878

879+
def __repr__(self):
880+
return (
881+
self.__class__.__name__
882+
+ "("
883+
+ ", ".join(str(mob) for mob in self.submobjects)
884+
+ ")"
885+
)
886+
879887
def add(self, *vmobjects):
880888
"""Checks if all passed elements are an instance of VMobject and then add them to submobjects
881889
@@ -934,6 +942,9 @@ def __init__(self, mapping_or_iterable={}, show_keys=False, **kwargs):
934942
self.submob_dict = {}
935943
self.add(mapping_or_iterable)
936944

945+
def __repr__(self):
946+
return __class__.__name__ + "(" + repr(self.submob_dict) + ")"
947+
937948
def add(self, mapping_or_iterable):
938949
"""Adds the key-value pairs to the :class:`VDict` object.
939950

0 commit comments

Comments
 (0)