object

How do I print class name in a method?

How do I print class name in a method? Question: I made a method and called onto it with super() but I do not know how to write the name of the class in a print statement! from abc import ABC, abstractmethod class Clothing(ABC): @abstractmethod def desc(self): pass class Shirt(Clothing): def desc(self): x = input(‘Enter …

Total answers: 1

create a list of an objectA inside the objectA

create a list of an objectA inside the objectA Question: When I’m trying to append() the object itself into a list inside the object, it doesn’t work, I don’t understand why. class PLayer: CLASS_NAME = "player" TOTAL_PLAYER_NUMBER = 0 TOTAL_PLAYER_LIST = [] PLAYER_ID_INCREMENT = 0 def __init__(self, name, first_name, birthday, note, player_id=None, total_score=None, tournament_score=None): self.PLAYER_ID_INCREMENT …

Total answers: 1

How to get/isolate the p-value from 'AnovaResults' object in python?

How to get/isolate the p-value from 'AnovaResults' object in python? Question: I want to use one way repeated measures anova in my dataset to test whether the values of 5 patients differ between the measured 3 days. I use AnovaRM from statsmodels.stats.anova and the result is an ‘AnovaResults’ object. I can see the p-value with …

Total answers: 2

Specify return type of a wrapper function that calls an abstract method in Python

Specify return type of a wrapper function that calls an abstract method in Python Question: For this example, consider the simplified scenario where a Solver will return a Solution. We have Solutions: class Solution(ABC): pass class AnalyticalSolution(Solution): pass class NumericalSolution(Solution): def get_mesh_size(self) -> float: return 0.12345 And Solvers: class Solver(ABC): def solve(self, task: int) -> …

Total answers: 1

Classes, attributes and functions in lmfit library

Classes, attributes and functions in lmfit library Question: I have a general problem that I don’t know how to navigate library modules to get the result that I want. Here is an example of what I mean: Let’s say I use lmfit library to do a fitting of a function: from lmfit import Model, Parameters …

Total answers: 1

Object has no attribute error when I name attribute with double underscores

Object has no attribute error when I name attribute with double underscores Question: I am trying to group all Patient objects by their surnames. My code: class Patient: def __init__(self, first_name, surname, age, mobile, postcode): self.__first_name = first_name self.__surname = surname self.__doctor = "None" self.__age = age self.__mobile = mobile self.__postcode = postcode self.__symptoms = …

Total answers: 1

How to retrieve an attribute from a list of instances properly

How to retrieve an attribute from a list of instances properly Question: I am unsure how to correctly get the attribute from a list of instances. Sorry if this seems simple, I am only a beginner. class Clown: def __init__(self,name,hours,job): self.name = name self.hours = hours self.job = job def get_job(self): return self.job def change_job(self, …

Total answers: 1

confusion because i can't figure out what is changing the attribute of the object of a class in python

confusion because i can't figure out what is changing the attribute of the object of a class in python Question: Here is my code ` class Cats: def __init__(self,name): self.name=name #print(self.name,name,"hello") def change_name(self,new_name): self.name=new_name return 0 #print(new_name) cat1=Cats("lion") print(cat1) print(cat1.name) cat2=cat1.change_name("tiger") print(cat1.name) print(cat1) print(cat2) ** Here is the output with my comments/opinion on the side …

Total answers: 1

How do I extract specific rows from a CSV file?

How do I extract specific rows from a CSV file? Question: I have three CSV files: doctors.csv 1,John,Smith,Internal Med 2,Jone,Smith,Pediatrics 3,Jone,Carlos,Cardiology patients.csv 1,Sara,Smith,20,07012345678,B1234 2,Mike,Jones,37,07555551234,L22AB 3,Daivd,Smith,15,07123456789,C1ABC … and linked.csv, which I need to populate based on doctors.csv and patients.csv. I’m taking two inputs from the user that correspond with the doctor ID and patient ID, and …

Total answers: 2