`if config['username'] and not config['password']`

boolean evaluations of python strings (or any python container) are true when the length is >0