Skip to content

Instantly share code, notes, and snippets.

@Fhernd
Created December 2, 2018 17:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fhernd/8ecada095153ef70d15692e31fefad0f to your computer and use it in GitHub Desktop.
Save Fhernd/8ecada095153ef70d15692e31fefad0f to your computer and use it in GitHub Desktop.
Cambiar la representación de cadena de caracteres de un objeto. Python.
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