class Humano:
def __init__(self, edad): #_init_ siempre va a ir en las clases. SELF es una palabra reservada, hace referencia a lo que se esta creando
self.edad= edad
print 'SOY UN NUEVO OBJETO'
def hablar(self, mensaje):
print mensaje
pedro=Humano(26)
raul=Humano(21)
print 'SOY PEDRO Y TENGO ', pedro.edad
print 'SOY RAUL Y TENGO ', raul.edad
pedro.hablar('HOLA')
raul.hablar('HOLA, PEDRO')
No hay comentarios:
Publicar un comentario