Created
December 2, 2018 17:33
-
-
Save Fhernd/8ecada095153ef70d15692e31fefad0f to your computer and use it in GitHub Desktop.
Cambiar la representación de cadena de caracteres de un objeto. Python.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Par: | |
def __init__(self, x:int, y:int): | |
self.x = x | |
self.y = y | |
def __repr__(self): | |
return 'Par({0.x!r}, {0.y!r})'.format(self) | |
def __str__(self): | |
return '({0.x!s}, {0.y!s})'.format(self) | |
par = Par(2, 3) | |
par | |
print(par) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment