Added password prompt #16
Merged
Spirit-act
merged 2 commits from feature-password-prompt
into master
6 years ago
Loading…
Reference in new issue
There is no content yet.
Delete Branch 'feature-password-prompt'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Resolves #15
Changes:
I think you could make this declaration cleaner by just having it as
There is a requirement for a check if the arg is empty.
I could have written it as a oneliner, but I think for beginners it is more understandable.
args_user_password = args.password if args.password is not None or not args.password else input('Enter your password: ')
args.password is not None or not args.password
Wouldn't this always be true? Not sure if I'm just missing something lol
I'd prefer either:
args.password if args.password else input('Enter your password: ')
orargs.password or input('Enter your password: ')
Generally it's a good idea in Python to rely on the fact that certain values are "falsey" instead of checking for explicit values like None or False.
Don't want to bikeshed too hard though. You could make it multiline instead of a oneliner too and it doesn't make a huge difference to me.
But if I use
args.password or input('Enter your password: ')
, the "empty" would not be caught. At least in my tests.@Spirit-act I'm not sure what you mean. I believe empty strings
''
evaluate to false?You can also do
args.password.strip()
if you're worried about whitespace, and it will evaluate toFalse
if the string is made up of whitespace.unfortunately not, my tests:
I want to catch your workaround with space:
But if you want, I'll change it to your preferences.
I don't think we need to worry about that getting caught by this. It's specific to bash and wouldn't be caught by this.
Ok, I have changed the code.
I'll give it a test run when I get a chance :) Thanks for the contribution
748bd851e7
.