Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Python
  3. Question
Python

Why am I receiving the error ‘Object has no attribute error in Python’?

Asked by Darsh K Jul 27, 2023 1.1K views 1 answer
Share

About this question

There is a class MyThread. I am trying to run the method sample from the same object context. Here’s the code:

Class mythread (threading,thread):
Def _init_9self, threadID, name, counter,
redis0psObj):
threading.Thread._init_(self)
self.threadID = ThreadID
Self.name = name
Self.counter = counter
self.redis0psObj = redis0psObj
Def stop (self):
Self.kill_received = True
Def sample (self):
Print “hello”
Def run (self):
Time.sleep (0.1)
Print “n Starting “ + self.name
self.sample()

On running, I am receiving the error

AttributeError : ‘my thread’ object has no attribute “sample”

What’s wrong?

Your answer

1 Answer

More Python discussions

Learn & Explore

Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.

Latest Python Blogs

Guides, tips and career advice on Python from JanBask experts.