Simple object for storing attributes. Implements equality by attribute names and values, and provides a simple string representation.
| 1170 | # =========================== |
| 1171 | |
| 1172 | class Namespace(_AttributeHolder): |
| 1173 | """Simple object for storing attributes. |
| 1174 | |
| 1175 | Implements equality by attribute names and values, and provides a simple |
| 1176 | string representation. |
| 1177 | """ |
| 1178 | |
| 1179 | def __init__(self, **kwargs): |
| 1180 | for name in kwargs: |
| 1181 | setattr(self, name, kwargs[name]) |
| 1182 | |
| 1183 | __hash__ = None |
| 1184 | |
| 1185 | def __eq__(self, other): |
| 1186 | return vars(self) == vars(other) |
| 1187 | |
| 1188 | def __ne__(self, other): |
| 1189 | return not (self == other) |
| 1190 | |
| 1191 | def __contains__(self, key): |
| 1192 | return key in self.__dict__ |
| 1193 | |
| 1194 | |
| 1195 | class _ActionsContainer(object): |