>> 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('> ') or myDefault

I reads well (IMHO) and works pretty much safely.

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to