[Tutor] __str__ Vs __repr__
Alex Kleider
alexkleider at gmail.com
Tue Nov 30 12:53:45 EST 2021
https://www.tutorialspoint.com/str-vs-repr-in-python
On Tue, Nov 30, 2021 at 9:06 AM Manprit Singh <manpritsinghece at gmail.com>
wrote:
> Dear Sir,
>
> After assigning a value to a variable, Lets say variable is a, and the
> value assigned to it is 5,
> On an interactive shell after writing a and then hitting Enter key, it
> prints the value of a, that is 5, This happens due to __str__ or __repr__?
>
> What should I use(__str__ or __repr__) if I want something to be printed
> when I print an object of a user defined class ?
> _______________________________________________
> Tutor maillist - Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
More information about the Tutor
mailing list