Y no es necesario hacer un A.__init__(self) O solo es necesario si quieres usar métodos de la otra clase
El 18 de marzo de 2011 19:26, Guido Castillo Gómez <gca...@gmail.com>escribió: > La consola interactiva de python ayuda mucho cuando tienes dudas sobre > sintaxis. > > class A(): > _v = None#Antes: self._v = None > > def __init__(self): > self.v="Hola" > > class B(A): > def mostrar(self): > print self.v > > c=B() > print c.v > print c.mostrar() > print c > > Saludos, > > El 18 de marzo de 2011 17:43, gabriel fernandez <gabofe...@gmail.com>escribió: > >> Hola Lista!! >> >> Tengo una duda sobre la herencia en Python: >> >> class A(): >> self._v = None >> def __init__(self): >> self.v="Hola" >> >> class B(A): >> def mostrar(self): >> print self.v >> >> c=B() >> print c.v >> print c.mostrar() >> >> El código anterior es correcto? >> >> Muchas gracias >> >> print c >> >> -- >> Gabriel Fernández >> Desrrollador Web >> www.openweb.com.uy >> >> >> >> _______________________________________________ >> Python-es mailing list >> Python-es@python.org >> http://mail.python.org/mailman/listinfo/python-es >> FAQ: http://python-es-faq.wikidot.com/ >> >> > > _______________________________________________ > Python-es mailing list > Python-es@python.org > http://mail.python.org/mailman/listinfo/python-es > FAQ: http://python-es-faq.wikidot.com/ > > -- lopz es libre, usa --> GNU/linux gentoo +--[RSA 2048]--+ | ..o.o=+ | | o =o*.+ | | . . *oO . | | .EBoo | | o.S | +--[lopz.org]--+
_______________________________________________ Python-es mailing list Python-es@python.org http://mail.python.org/mailman/listinfo/python-es FAQ: http://python-es-faq.wikidot.com/