Flask: differences between request.form["xxxxx"], request.form.get("xxxxxx") and request.args.get("xxxxx")?
<p>What are the differences between <code>flask.request.form["xxx"]</code> , <code>flask.request.form.get("xxx")</code> and <code>flask.request.args.get("xxx")</code> ?  </p>

<p>I have this question because I am using flask-login to handle authentication.<br>
In particular in the following code (taken from the flask-login github page), I don't understand why with <code>req.form.get("email")</code>, email is <code>None</code>, while with <code>req.form["email"]</code>, email hasn't a value. Here's the code. </p>

<pre><code>@login_manager.request_loader
def request_loader(req):
    email = req.form.get('email')
    if email not in users:
        return

    user = User()
    user.id = email

    # DO NOT ever store passwords in plaintext and always compare password
    # hashes using constant-time comparison!
    user.is_authenticated = req.form['pw'] == users[email]['pw']

    return user
</code></pre>

<p>The proper use-case get() is to return a default value when the key you are looking for doesn't exist in a dictionary.</p>

<p>For example, if you have a dictionary d such that :</p>

<pre><code>d = {'foo': 'bar'}
</code></pre>

<p>Doing the following will return None:</p>

<pre><code>d.get('baz', None)
</code></pre>

<p>While doing the following will throw an exception:</p>

<pre><code>d['baz']
</code></pre>

python flask flask-login