def name_for(obj):
"""
Get a name for something.
Allows overriding of default names using the `__alias__` attribute.
"""
if isinstance(obj, string_types):
return obj
cls = obj if isclass(obj) else obj.__class__
if hasattr(cls, "__alias__"):
return underscore(cls.__alias__)
else:
return underscore(cls.__name__)
评论列表
文章目录