Python. Did I understand the code correctly? -
i have little question. piece of code means: "whenever instance of class mythread created, initialize threading.thread constructor , assign passed arguments variables inside mythread class". class creates instance of threading.thread class , adds little bit of custom functionality, such new variables. right?
class mythread(threading.thread): def __init__(self, func, args, name=''): threading.thread.__init__(self) self.name = name self.func = func self.args = args
if correct, piece of code
class mythread(threading.thread): def __init__(self): threading.thread.__init__(self)
simply creates instance of threading.thread class , in fact same can done putting a = threading.thread()
. correct?
yes.
class mycls(basecls): def __init__(self): basecls.__init__(self)
is same as
class mycls(basecls): pass # constructor not overriden
basecls
constructor called in both cases when creating mycls
objects.
mycls
(when "empty") , basecls
still different things, there differences if example basecls
uses __slots__
.
Comments
Post a Comment