__str__ vs __repr__ In Python

Publié le: 07 novembre 2020
sur la chaîne: Finxter
332
8

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...


Sur cette page du site, vous pouvez voir la vidéo en ligne __str__ vs __repr__ In Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Finxter 07 novembre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 332 fois et il a aimé 8 téléspectateurs. Bon visionnage!