Skip to content

Instantly share code, notes, and snippets.

@dboyliao
Last active December 29, 2015 01:26
Show Gist options
  • Save dboyliao/509e6004fadef1238257 to your computer and use it in GitHub Desktop.
Save dboyliao/509e6004fadef1238257 to your computer and use it in GitHub Desktop.
class People:
def __init__(self, name):
self.name = name
def __str__(self):
return "Hello, I'm {}".format(self.name)
def __repr__(self):
return "<type People>: name = '{}'".format(self.name)
p = People("Qmal")
print(p)
# >>> "Hello, I'm Qmal"
repr(p)
# >>> "<type People>: name = 'Qmal'"
str(p)
# >>> "Hello, I'm Qmal"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment