problem with user confirmation
Duncan Smith
buzzard at urubu.freeserve.co.uk
Thu Sep 18 19:39:33 EDT 2003
More information about the Python-list mailing list
Thu Sep 18 19:39:33 EDT 2003
- Previous message (by thread): Unicode 4.0 updates to unicodedata?
- Next message (by thread): problem with user confirmation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
"Matthew" <ruach at chpc.utah.edu> wrote in message news:ec1162c7.0309181523.2077b7e5 at posting.google.com... > I am have written a medium sized program and everything works fine > except for one piece. At a certain point in the program I want to do a > simple user confirmation, eg Are you sure ? y/n. The problem that I am > having is that after the user enters an answer and presses enter, the > program executes the rest of the code regardless of what the user > response was. > > Heres my code: > > def confirmAction(self, msg): > if not msg: > msg = 'Are you sure y/[n]> ' > print msg > confirm = sys.stdin.readline()[:-1] > print 'confirm = \'%s\'' %(confirm) > if confirm == 'y' or 'Y' or 'Yes' or 'YES' or 'yes': > return 1 > return 0 [snip] 'Y' evaluates to true. Maybe try something like: if confirm in ['y', 'Y', 'Yes', 'YES', 'yes']: etc. Duncan
- Previous message (by thread): Unicode 4.0 updates to unicodedata?
- Next message (by thread): problem with user confirmation
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list