Create inscance of a Thread class within the same file in python?

I’m trying to create an instance of a Thread type class called A within the class B that’s in the same file.

I tried some combinations x = A(i), x = A.A(i), x = A.__init(i) and so on…

from threading import Thread

class A(Thread):
    def __init__(self, i)
        Thread.__init__(self)
        self.i = i

    def run(self):
        print('foo')

class B()
    def __init__(self):
        x = #instance of A ?
        x.start()

if __name__ == '__main__':
    B() # Here I call the class B that should start the thread of A

I need to call the class. And not a method inside the class. Because I want then to call the x.start() method to start the thread.


Download create.inscance.of.a.thread.class.within.the.same.file.in.python.zip
Direct Link


Download


Download create.inscance.of.a.thread.class.within.the.same.file.in.python.zip
Mediafire


Download


Download create.inscance.of.a.thread.class.within.the.same.file.in.python.zip
Filerio


Download

Both comments and pings are currently closed.

Comments are closed.