Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Boolean return values swapped for prompt.yn with default="n" #145

Open
eiszfuchs opened this issue Jul 29, 2015 · 2 comments
Open

Boolean return values swapped for prompt.yn with default="n" #145

eiszfuchs opened this issue Jul 29, 2015 · 2 comments

Comments

@eiszfuchs
Copy link

I couldn't find an issue dealing with this problem.
Have this example code:

from clint.textui import prompt

for d in range(3):
    print(prompt.yn("Yes?"))

for y in range(3):
    print(prompt.yn("Yes? default=y", default="y"))

for n in range(3):
    print(prompt.yn("Yes? default=n", default="n"))

Output is:

Yes? [Y/n] y
True
Yes? [Y/n] n
False
Yes? [Y/n] 
True
Yes? default=y [Y/n] y
True
Yes? default=y [Y/n] n
False
Yes? default=y [Y/n] 
True
Yes? default=n [y/N] y
False
Yes? default=n [y/N] n
True
Yes? default=n [y/N] 
True

If I chose "n" for default, the boolean value is negative.
I think this line should be the other way round:
https://github.com/kennethreitz/clint/blob/master/clint/textui/prompt.py#L59

@wkentaro
Copy link
Contributor

wkentaro commented Aug 8, 2015

+1

I think the function prompt::yn should return False even if the default value is n as user input for "don't do that".
So, expecting behavior is:

Yes? default=n [y/N] y
True
Yes? default=n [y/N] n
False
Yes? default=n [y/N] 
False

@tz70s
Copy link

tz70s commented Sep 3, 2015

+1

I modify the prompt.yn as the issue talking about , and pull a request
I think maybe the author would more like the return value as the input match the default value ?

thank you guys

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants