Claudio Freire wrote:
> edad = None
> def edadInvalida():
> yield True
> while not edad.isdigit():
> print "No es un número"
> yield True
> for i in edadInvalida():
> edad = raw_input("Edad plis: ")
>
> Hay algo que no me gusta de eso. No puedo decir exactamente qué... pero
> algo me huele feo.
¿Usar edad 'globalmente'?
def valida(edad):
if edad is not None
if edad.isdigit()
print "Un número, vieja..."
return false
edad = None
while not valida(edad):
edad = raw_input("Edad")
Aunque sigue siendo feo porque estamos imprimiendo cosas desde el
validador...
--
Guillermo O. «Tordek» Freschi. Programador, Escritor, Genio Maligno.
http://tordek.com.ar :: http://twitter.com/tordek
http://www.arcanopedia.com.ar - Juegos de Rol en Argentina