>> With raw_input(), it allows to input value. Can it be used to input value
>> with default value option?
>>
> response = raw_input("Enter some data:")
> if not response: response = "default value"
This is one of the few places where I do use the short-circuit evaluation
trick:
val = raw_input
> With raw_input(), it allows to input value. Can it be used to input
> value with default value option?
Hi Phon,
We can build your own function to do this. Bob showed how to set up code
so that the default's taken if the user just presses enter in his reply.
Let's take a look at it again:
Keo Sophon wrote:
> Hi,
>
> With raw_input(), it allows to input value. Can it be used to input value
> with default value option?
>
response = raw_input("Enter some data:")
if not response: response = "default value"
___
Tutor maillist - Tutor@pyt
Hi,
With raw_input(), it allows to input value. Can it be used to input value with
default value option?
Phon
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor