Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

module object has no attribute 'thread'

I was using basic threading. This was the code I typed.

#!usr/bin/python3

import threading
class Bhai_ka_messenger(threading.Thread):
    def run(self):
        for message in range(10):
            print threading.currentThread().getName()

a=Bhai_ka_messenger(name="message send")
b=Bhai_ka_messenger(name="message receive")
a.start()
b.start()

This says module object has no attribute thread. When I run this on an online IDE, this program works. Now I am not able to sort this problem,can anyone help?

like image 280
Kaustubh Mundra Avatar asked Mar 12 '23 05:03

Kaustubh Mundra


1 Answers

You have called your local file threading.py, but then import that file inside the file itself, causing it not to work.

I hope this can help you.

like image 59
WHOAMI Avatar answered Mar 19 '23 18:03

WHOAMI