Skip to content

Instantly share code, notes, and snippets.

@Chavao
Created September 24, 2013 17:43
Show Gist options
  • Save Chavao/6688518 to your computer and use it in GitHub Desktop.
Save Chavao/6688518 to your computer and use it in GitHub Desktop.
Criando uma "interface" em Python
class Usuario(object):
def nome(self):
raise NotImplementedError
def idade(self):
raise NotImplementedError
class Jose(Usuario):
def nome(self):
return 'Jose'
def idade(self):
return 20
class Maria(Usuario):
def idade(self):
return 15
j = Jose()
m = Maria()
print j.nome()
print m.nome() # Lança exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment