code: def get_password(from_stdin_only=False):
      
      if not sys.stdin.isatty():
          password = sys.stdin.readline().strip()
      elif not from_stdin_only:
          password = getpass.getpass('Enter the password: ')
      else:
          password = None
  
      return password
docs: Get a password either from STDIN or by prompting the user.
  
      :return: the password.