django request.session.get("name", False) - What does this code mean?

If session has a key in it with the value "name" it returns the value associated with that key (which might well be False), otherwise (if there is no key named "name") it returns False.

The session is a dictionary-like type so the best place to get documenation on the get method is in the Python docs for the standard library. The short of the matter is that get is shorthand for the following:

if "name" in request.session:
    result = request.session["name"]
else:
    result = False

if result:
    # Do something

Tags:

Python

Django