dropbox / python-zxcvbn

A realistic password strength estimator.
https://tech.dropbox.com/2012/04/zxcvbn-realistic-password-strength-estimation/
MIT License
254 stars 53 forks source link

Allow empty user inputs #7

Closed ziima closed 11 years ago

ziima commented 11 years ago
rpearl commented 11 years ago

I think we should just make user_inputs=[] the function default instead?

ziima commented 11 years ago

Never do that in python, for example http://stackoverflow.com/questions/1132941/least-astonishment-in-python-the-mutable-default-argument

rpearl commented 11 years ago

That is true if we modify the input parameter, but we treat it immutably in zxcvbn. The following is completely fine in python and is (arguably) the right way to do things:

def f(a=[]):
    print a

f()
f(a=[1])
f()
ziima commented 11 years ago

It is fine for now, but you never know, what changes you will do some day. Generally it is bad practice to use empty lists/dicts/any mutable as default arguments, even if you treat it immutably.