Python UserDict.DictMixin.setdefault() Examples
The following are 2
code examples of UserDict.DictMixin.setdefault().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
UserDict.DictMixin
, or try the search function
.
Example #1
Source File: http_headers.py From python-for-android with Apache License 2.0 | 5 votes |
def copy(self): """ Return a C{dict} mapping each header name to the last corresponding header value. """ return dict(self.items()) # Python 2.3 DictMixin.setdefault is defined so as not to have a default # for the value parameter. This is necessary to make this setdefault look # like dict.setdefault on Python 2.3. -exarkun
Example #2
Source File: http_headers.py From python-for-android with Apache License 2.0 | 5 votes |
def setdefault(self, name, value=None): """ Retrieve the last value for the given header name. If there are no values present for that header, set the value to C{value} and return that instead. Note that C{None} is the default for C{value} for backwards compatibility, but header values may only be of type C{str}. """ return DictMixin.setdefault(self, name, value) # The remaining methods are only for efficiency. The same behavior # should remain even if they are removed. For details, see # <http://docs.python.org/lib/module-UserDict.html>. # -exarkun