Snippets tagged “string-representation”
3 snippets use this tag.
- How to print instances of a class using print()?Python
To print instances of a class using the built-in print() function, you can define a __str__ method within the class.
- StringBuilder vs String concatenation in toString() in JavaJava
In Java, you can use either a StringBuilder or string concatenation to create a string representation of an object.
- What is the difference between __str__ and __repr__?Python
__str__ and __repr__ are two special methods in Python classes.