__init__和self在Python中做什么?

问题描述我正在学习Python编程语言,我遇到了一些我不完全理解的事情。使用如下方法:defmethod(self,blah):def__init__(?):........self做什么?这意味着什么呢?这是强制的吗?方法的作用是什么?为什么这是必要的?(等)我认为它们可能是O

发布:2022-10-16 标签:pythonoopself


Python类:覆盖`self`

问题描述在我的python脚本中,我有一个存储Processo对象的全局存储(一个简单的全局dict)。它是在我的程序执行过程中填满的。由于性能原因,它的存在是为了避免创建重复的Processo对象。因此,对于classProcesso,我希望在创建期间验证它是否已在全局存储上。

发布:2022-10-16 标签:pythonstoragepython-3.xselfglobals


UIButton addTarget Self是如何工作的?

问题描述我尝试找出为什么self指向GameViewController而不是答案GameViewController.swiftclassGameViewController:UIViewController{vargameplay=QuestionsController(co

发布:2022-10-16 标签:iosswiftselfuibuttonaddtarget


__init__ 和 self 在 Python 中做了什么?

问题描述I'mlearningthePythonprogramminglanguageandI'vecameacrosssomethingIdon'tfullyunderstand.Inamethodlike:defmethod(self,blah):def__init__(?)

发布:2022-10-16 标签:pythonoopself


PHPUnit - 使用 $this 或 self 作为静态方法?

问题描述我不想写长文,因为这是一个简短的问题.PHPUnit测试包含几个静态方法.例如所有那些PHPUnitFrameworkAssert::assert*()方法以及identicalTo、equalTo.Idon'twanttowritealongtext,becauseit

发布:2022-10-16 标签:phpoopunit-testingselfphpunit


在 Objective-C 中分配给自己

问题描述我来自C++世界,所以分配this的想法让我不寒而栗:I'mfromtheC++worldsothenotionofassigningthismakesmeshudder:this=newObject;//Gah!但在Objective-C中有一个类似的关键字,self,

发布:2022-10-16 标签:initializationobjective-cself


self.delegate = 自我;这样做有什么问题?

问题描述self.delegate=self;这样做有什么问题?正确的做法是什么?self.delegate=self;what'swrongindoingthat?andwhatisthecorrectwayofdoingit?谢谢,尼尔.代码:(UITextField*)in

发布:2022-10-16 标签:iphonedelegatesselfuitextfield


对内置对象的属性分配

问题描述这行得通:classMyClass(object):passsomeinstance=MyClass()someinstance.myattribute=42printsomeinstance.myattribute>>>42但这不是:someinstance=objec

发布:2022-10-16 标签:pythonattributesinitializationself


函数是否有引用自身的通用方法?

问题描述我可以通过以下代码访问函数本身内部的python函数的属性:Icanaccessapythonfunction'sattributeinsideoffunctionitselfbybelowcode:defaa():printaa.__name__printaa.__ha

发布:2022-10-16 标签:pythonfunctionreferenceself


何时使用“self"访问属性

问题描述我已在本网站上阅读了许多有关此问题的问题,我了解以下内容:Ihavereadanumberofquestionsonthissiteaboutthisissue,Iunderstandthefollowing:self.property访问手动或@synthesize创建

发布:2022-10-16 标签:propertiesobjective-cselfretain