-
Notifications
You must be signed in to change notification settings - Fork 3
Needed choice on python 2.6 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,23 @@ | ||
| import choice | ||
|
|
||
| def c(): | ||
| print("Delete confirmed") | ||
|
|
||
| # Get a yes or no response (default is no) | ||
| confirm = choice.Binary('Are you sure you want to delete?', False).ask() | ||
| if confirm: | ||
| deleteIt() | ||
| c() | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey @bastbnl, any reason to put this in a separate
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No particular reason. I noticed confirming the question stops the test script as the function is undefined. A separate function is not required at all and printing a message would make sense |
||
|
|
||
| # Input an arbitrary value, check for correctness | ||
| howmany = choice.Input('How many pies?', int).ask() | ||
| print("You ordered {} pies".format(howmany)) | ||
| print("You ordered {0} pies".format(howmany)) | ||
|
|
||
| # Choose from a set of options | ||
| entree = choice.Menu(['steak', 'potatoes', 'eggplant']).ask() | ||
| print("You choice {}".format(entree)) | ||
| print("You choice {0}".format(entree)) | ||
|
|
||
|
|
||
| posts = ['post {}'.format(num) for num in range(15)] | ||
| posts = ['post {0}'.format(num) for num in range(15)] | ||
|
|
||
| resp = choice.Menu(posts, ['edit', 'delete', 'publish'], ['newpost', 'exit']).ask() | ||
| print(resp) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! I think you could put this at the top of the class:
Or alternatively, edit
idNameList()to return[]when the input is None. This would prevent other crashes, e.g. here:https://github.com/fyhuang/choice/pull/3/files#diff-ea6df2eb5ce078088b03f5d6e6365c16L33