>> Is there a better way for raw_input to accept both caps and 
>> lower case letters than:
[...]
>>    if action == 'y' or action == 'Y':
>
> if action in 'yY':
> dostuff()
[...]
> Although, that does mean that if a user enters 'nN' they'll 
> get no, but that shouldn't be a huge problem, and it it does, 
> you can just do a if len(action) != 1...

Alternatively, you could do:

    if action.lower() == 'y':

This is the most readable, IMO, but is probably slower (function calls are
expensive) than 'if len(action) == 1 and action in "yY"' or 'if action ==
"y" or action == "Y"'.  (Of course, the difference in speed here is almost
certainly irrelevant).

=Tony.Meyer

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

Reply via email to