The following is part of SqlAlchemy, I'm trying to figure out how this is valid Python syntax. I know the code works, I'm just trying to understand what is is doing here and how that is valid. These are NOT nested classes, they are stand alone classes. I would have expected a pass after each class declaration though and I'm pretty sure it not being there is significant.
class InstrumentedList(list):
"""An instrumented version of the built-in list."""
class InstrumentedSet(set):
"""An instrumented version of the built-in set."""
class InstrumentedDict(dict):
"""An instrumented version of the built-in dict."""
__canned_instrumentation = {
list: InstrumentedList,
set: InstrumentedSet,
dict: InstrumentedDict,
}
__interfaces = {
list: (
{'appender': 'append', 'remover': 'remove',
'iterator': '__iter__'}, _list_decorators()
),
set: ({'appender': 'add',
'remover': 'remove',
'iterator': '__iter__'}, _set_decorators()
),
# decorators are required for dicts and object collections.
dict: ({'iterator': 'values'}, _dict_decorators()) if util.py3k
else ({'iterator': 'itervalues'}, _dict_decorators()),
}