Python best practices — can I set an object attribute to call a class method?

I am building a tool to query all DNS records for a hostname. Each hostname will create a ScanObject object, which will call another module to do the queries upon instantiation. I create class methods …

Return value from function within a class using multiprocessing

I have following piece of codes, which I want to run through multiprocessing, I wonder how can I get return values after parallel processing is finished. I prefer not to make any change to getdata …

attributeError when calling method of object class

from PyQt5 import uic from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * QApplication.setAttribute(Qt.AA_EnableHighDpiScaling) app = QApplication([]) window = uic….

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 …

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: class course: …

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 …

Defining a classmethod outside of a class in Python [closed]

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 have custom screens made for you. I need each screen to have different …

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 …

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 …

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: def instance_but_not_subclass(object, …