Why am I getting AttributeError: Object has no attribute?
Your indentation is goofed, and you've mixed tabs and spaces. Run the script with python -tt
to verify.
AttributeError: '...' object has no attribute '...'
In the ticket
class you are trying to assign new instance attributes from methods that don't exist.
Try removing the self
from the assignments in the ticket
constructor.
Like this:
class ticket(object):
counter = 2000
def __init__(self):
self.name = 'Ticket'
self.tc = ticketCreation() # ticketCreation constructor has parameters.
self.sr = supportResponse() # supportResponse class does too
self.pc = callPassword()
AttributeError: '' object has no attribute ''
Your NewsFeed
class instance n
doesn't have a Canvas
attribute. If you want to pass the Canvas
defined in your Achtergrond
class instance hoofdscherm
to n
, you can define it under the class definition for NewsFeed
using __init__()
:
class NewsFeed ():
def __init__(self, canvas):
self.canvas = canvas
...
Then when you initialize your NewsFeed
object as n
, you can pass the Canvas
instance from your Achtergrond
class instance hoofdscherm
:
n = NewsFeed(hoofdscherm.canvas)
This is a solution to your current issue, but there are other errors in your code that you can see once you modify it.
Related Topics
Differencebetween Slice Assignment That Slices the Whole List and Direct Assignment
How to Write a Multidimensional Array to a Text File
Why Is Parenthesis in Print Voluntary in Python 2.7
How to Convert a Datetime to Date
Matplotlib Scatter Plot Legend
Why Does '.Sort()' Cause the List to Be 'None' in Python
Weird Try-Except-Else-Finally Behavior with Return Statements
Using Logging in Multiple Modules
Adding a Module (Specifically Pymorph) to Spyder (Python Ide)
How to Flatten a Nested JSON Recursively, with Flatten_JSON
How to Get a Random Number Between a Float Range
How to Make a Tkinter Window Jump to the Front
Setting Different Color for Each Series in Scatter Plot on Matplotlib
Multi-Level Defaultdict with Variable Depth
Cartesian Product of Two Lists in Python