Name
getfirst
Synopsis
f.getfirst(key,default=None)When
f
.has_key(
key
),
and
f
[
key
].value
is a single value, not a list of values, getfirst
returns
f
[
key
].value.
When
f
.has_key(
key
),
and
f
[
key
].value
is a list of values, getfirst returns
f
[
key
].value[0].
When key is not a key in
f, getfirst returns
default.
Use getfirst when you know that there should be
just one input field (or at most one input field) named
key in the form from which your
script’s input comes. getfirst
was introduced in Python 2.2, so don’t use it if
your script must remain compatible with older versions of Python.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access