Article Link: https://blog.finxter.com/python-__str...
The key goal of _str_ and _repr_ is to return a string representation of a Python object. The way they represent the string object differentiates them.
str() & _str()_ return a printable/readable string representation of an object which is focused on the end-user.
repr() & _repr()_ return a string representation of an object that is a valid Python object, something you can pass to eval() or type into the Python shell without getting an error. Its major goal is to be unambiguous.
_______________________________________________________________________________________________
Do you want to thrive as a self-employed Python freelancer controlling your own time, income, and work schedule? Check out our Python freelancer resources:
Finxter Python Freelancer Course:
https://blog.finxter.com/become-pytho...
Finxter Python Freelancer Webinar:
https://blog.finxter.com/webinar-free...
Leaving the Rat Race with Python (Book):
https://blog.finxter.com/book-leaving...
On this page of the site you can watch the video online __str__ vs __repr__ In Python with a duration of hours minute second in good quality, which was uploaded by the user Finxter 07 November 2020, share the link with friends and acquaintances, this video has already been watched 332 times on youtube and it was liked by 8 viewers. Enjoy your viewing!