[Tutor] func-question_y_n.py
Mitya Sirenef
msirenef at lightbird.net
Sat Mar 16 01:30:26 CET 2013
On 03/15/2013 05:47 PM, Christopher Emery wrote:
> Hi Mitya,
>
> Thank for your example of code, however at this time its well over my
> head and I think its best if I slowly work on a function that provided
> only what I need and then add to it IF it works into it. Yours
> appears to do a whole lot more then process a Yes/No from a question
> and re-ask the question if the user does not provide a yes or no.
>
> I will save your code for future use as I understand it more (smile)
Ok, sorry if it was too much.. in short, the advantage is that it can
accept yes/no but you can also specify any other pattern, e.g. to accept
a number or a string that's not shorter or longer than specified, or
accept a blank response; it uses regular expressions to match pattern:
http://docs.python.org/3.3/library/re.html
-m
--
Lark's Tongue Guide to Python: http://lightbird.net/larks/
More information about the Tutor
mailing list