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
Tag: class
In PyQT why somes widgets needs the “self” parameter before calling them, while others don’t
I’m a little bit confused about the use of the “self” parameter with some widgets like (QLineEdit), indeed when learning to use the QLabel widget, I used to call the class without the self paramater, or when using the QLineEdit widget, the widget wouldn’t work without the “self” parameter, here’s the code I’m working on : So here is where
Why can’t I initialize instances using for loop – Python, class
error: name ‘w1’ is not defined I tried to use for loop to initialize all the workers( w1, w2, w3) so i can access them afterwards. But when I try to access them they say the instance is not defined, is it possible that you cant initialize using for loop. Thanks in advance, beginner here. Answer I think the best
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
Defining a classmethod outside of a class in Python [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I am making a game with Pygame where there are going to be many different screens. I am making a class called Screen that will
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
how to make a temporary object from withing the class function in python?
I’m writing this code and there is a need to send objects as parameters in functions. My problem is one of the objects needs to be resued with its original values but as I need to return an object from the functions. I don’t know how I can send the answer and keep the original values in the object safe
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