对于元组、列表、字符串等类型的变量,在其上面加上星号(*)然后传递,其效果是将该变量数据进行unpack(解包)后在传递。
扩展阅读:知乎:元组的reference前加个星号是什么意思?
根据字符串获取某对象以该字符串命名的属性/方法:
def getattr(object, name, default=None): # known special case of getattr
"""
getattr(object, name[, default]) -> value
Get a named attribute from an object; getattr(x, 'y') is equivalent to x.y.
When a default argument is given, it is returned when the attribute doesn't
exist; without it, an exception is raised in that case.
"""
根据字符串查询某对象是否有以该字符串命名的属性/方法:
def hasattr(p_object, name): # real signature unknown; restored from __doc__
"""
hasattr(object, name) -> bool
Return whether the object has an attribute with the given name.
(This is done by calling getattr(object, name) and catching exceptions.)
"""
stackoverflow - Python: Once and for all. What does the Star operator mean in Python?
A Guide to Python's Magic Methods
Event driven framework for Python