1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#------------------------------------------------------------------------------
# Copyright (c) 2013-2025, Nucleic Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file LICENSE, distributed with this software.
#------------------------------------------------------------------------------
class ObjectDict(dict):
""" A dict subclass which allows access by named attribute.
"""
__slots__ = ()
def __getattr__(self, attr):
if attr in self:
return self[attr]
msg = "'%s' object has no attribute '%s'"
raise AttributeError(msg % (type(self).__name__, attr))
|