2009/9/16 Patricio Molina <patriciomolina@???>
> 2009/9/16 Facundo Batista <facundobatista@???>
>
>> On Wed, Sep 16, 2009 at 2:30 PM, Manuel Aráoz <manuelaraoz@???>
>> wrote:
>>
>> > mucho más lindo lo que propusieron de
>> >
>> > while not edad.isdigit():
>> > print "No ingresaste un nro!"
>> > edad = raw_input()
>>
>> El problema acá es que tenés dos veces el raw_input(), con lo cual si
>> tenés que cambiar el mensaje tenés que tocar dos lados del código, y
>> seguro que en algún momento te olvidás de uno y te queda desparejo...
>>
>
> Para eso existe el "do while", que corre 1 a n veces. Creo que no existe en
> Python, no?
>
> do:
> algo = raw_input('Ingrese algo: ')
> while not algo
>
> Saludos
>
> --
> Patricio M. Molina
> http://patriciomolina.com/
>
Casualmente, encontré esto:
http://www.python.org/dev/peps/pep-0315/(Enhanced While Loop)
"This PEP proposes to solve these problems by adding an optional clause to
the while loop, which allows the setup code to be expressed in a natural
way:
do:
<setup code>
while <condition>:
<loop body>
This keeps the loop condition with the while keyword where it belongs, and
does not require code to be duplicated."
Saludos
--
Patricio M. Molina
http://patriciomolina.com/