Skip to content
Advertisement

Tag: class

attributeError when calling method of object class

Trying to animate a car with button to accelerate and decelerate. When I press a button to accelerate/decelerate, I get an error in the ‘if’ statements on both methods “AttributeError: ‘bool’ object has no attribute ‘speed'”. Can someone help me figure out what’s going wrong? Thank you! Answer You should pass to clicked.connect a method bound to the object in

Is it possible to create nested class attributes?

I’m pretty new to Python and have recently learned about classes. I’ve been experimenting around with them and have come up with a student/course grading system. Here’s the code so far: So this creates a course class, which I can add students to and set their rooms and other stuff. I’ve got another class, which is intended to store information

Why is my class object not working as intended?

I have two issues that need resolving. I have created a class object LoanInstance. The object should create a list of numbers (int or float) that show different aspects of a personal loan repayment balance. There are 2 main parts to the object. Part 1: Read in data from a data frame (I’ve created an example data frame below) df

Python: get attribute from class objects stored in an array

I would like to get the attribute of every object contained in an ndarray. Consider the following code, where after vectorization the function returns an ndarray with the objects. From each of these objects in the array, I would like to get the attribute and store the attributes in a new array. The classes and functions are a dummy for

Can’t define class in python [closed]

Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 2 years ago. Improve this question CODE:: Error:: Traceback (most recent call last): File “C:/Users/Jedi/PycharmProjects/LMS/main.py”, line 5, in class

Check if an item is an instance but not a subclass

How can you check if an object is an instance of a class but not any of its subclasses (without knowing the names of the subclasses)? So if I had the below code: what would go in the #code space that would produce the output?: Because issubclass() and isinstance() always return True. Answer The object.__class__ attribute is a reference to

Advertisement