def _get_attrs(obj):
from types import DictProxyType
if not hasattr(obj, '__dict__'): # pragma: no cover
return [] # slots only
if not isinstance(obj.__dict__,
(dict, DictProxyType)): # pragma: no cover
raise TypeError("{}.__dict__ is not a dictionary".format(
obj.__name__))
return obj.__dict__.keys()
# https://stackoverflow.com/questions/
# 15507848/the-correct-way-to-override-the-dir-method-in-python
评论列表
文章目录