Get and remove an attribute by name. Like :meth:`dict.pop`. :param name: Name of attribute to pop. :param default: Value to return if the attribute is not present, instead of raising a ``KeyError``. .. versionadded:: 0.11
(self, name: str, default: t.Any = _sentinel)
| 76 | return self.__dict__.get(name, default) |
| 77 | |
| 78 | def pop(self, name: str, default: t.Any = _sentinel) -> t.Any: |
| 79 | """Get and remove an attribute by name. Like :meth:`dict.pop`. |
| 80 | |
| 81 | :param name: Name of attribute to pop. |
| 82 | :param default: Value to return if the attribute is not present, |
| 83 | instead of raising a ``KeyError``. |
| 84 | |
| 85 | .. versionadded:: 0.11 |
| 86 | """ |
| 87 | if default is _sentinel: |
| 88 | return self.__dict__.pop(name) |
| 89 | else: |
| 90 | return self.__dict__.pop(name, default) |
| 91 | |
| 92 | def setdefault(self, name: str, default: t.Any = None) -> t.Any: |
| 93 | """Get the value of an attribute if it is present, otherwise |