0

I wrote the follow program but it didn't work.What wrong with it?

def h(self):
    print "Hello World"
if __name__ == '__main__':
    hello = type('HelloThread', bases=(threading.Thread,object), dict=dict(hello=h))

The error when it run is that:

TypeError: type.__init__() takes no keyword arguments

My python version is the python2.7

1
  • 1
    What are you trying to achieve? What is the expected output? Commented Jan 16, 2017 at 12:22

1 Answer 1

3

The error specifically says type.__init__() takes no keyword arguments so don't use keyword arguments when initiating type:

hello = type('HelloThread', (threading.Thread, object), dict(hello=h))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.