Closed calderonsamuel closed 1 year ago
The default print()
method calls str()
in order to generate a compact representation suitable for display in a bulleted list. So if you wanted to customise this display, you could also provide a method for str()
. str()
methods are a little trickier than print methods, but you can see the most important ideas in the str.S7_object()
implementation:
nest.lev
argumentnest.lev
is greater than 0, output a space before anything elsestr()
recursively, make sure to increment nest.lev
.indent.str
argument, which you can see here.
This is just a toy example.
Here I define a custom_property class and its print method. It behaves as expected.
However, if I use the class as a property of a new class, another print method is used.
If I access the property it behaves as expected.
Is there a way to make the print method from the
foo
class "respect" the print method of thecustom_property
class? Should I just define a print method forfoo
?Created on 2023-09-12 with reprex v2.0.2