用法:
object.__set_name__(self, owner, name)在创建所属类
owner时自动调用。该对象已分配给该类中的name:class A: x = C() # Automatically calls: x.__set_name__(A, 'x')如果类变量是在类创建后赋值的,
__set_name__()不会被自动调用。如果需要,可以直接调用__set_name__():class A: pass c = C() A.x = c # The hook is not called c.__set_name__(A, 'x') # Manually invoke the hook有关更多详细信息,请参阅创建类对象。
3.6 版中的新函数。
相关用法
- Python object.__init_subclass__用法及代码示例
 - Python object()用法及代码示例
 - Python os.path.normcase()用法及代码示例
 - Python os.read()用法及代码示例
 - Python os.DirEntry.inode()用法及代码示例
 - Python os.closerange()用法及代码示例
 - Python os.set_blocking()用法及代码示例
 - Python os.pathconf()用法及代码示例
 - Python os.chflags()用法及代码示例
 - Python operator.truth()用法及代码示例
 - Python operator.le()用法及代码示例
 - Python os.WCOREDUMP()用法及代码示例
 - Python os.fork()用法及代码示例
 - Python os.ctermid()用法及代码示例
 - Python os.mkfifo()用法及代码示例
 - Python os.tcsetpgrp()用法及代码示例
 - Python os.path.commonpath()用法及代码示例
 - Python os.path.splitdrive用法及代码示例
 - Python os.mkdir()用法及代码示例
 - Python os.close()用法及代码示例
 
注:本文由纯净天空筛选整理自python.org大神的英文原创作品 object.__set_name__。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
