Category : self

Here is my code so far: class Circle: """Class to create Circle objects""" def __init__(self, radius=1, history=list()): """Circle initializer""" try: self.radius = radius self.history = history.append(radius) except ValueError: print("Radius cannot be negative!") if self.radius < 0: raise ValueError def __str__(self): return f’Circle with a radius of {self.radius}’ def __repr__(self): return f’Circle(radius={self.radius})’ @property def radius(self): return ..

Read more

I am essentially trying to assign a distinct variable to each element from a list. I attached some code below to better explain what I mean: class Skill: def __init__(self, name): skill_detail = SKILLS_LIST[name].values() self.one = skill_detail[0] self.two = skill_detail[1] self.three = skill_detail[2] self.four = skill_detail[3] self.five = skill_detail[4] self.six = skill_detail[5] self.seven = skill_detail[6] ..

Read more

the last error then i finish this snake, so i put while boucle in a def and i used self. i’m in about over one day and my brain will be melted ^^ #libraries import pygame import time import random from tkinter import * snake= Tk() snake.title(‘SNAKE GAME’) snake.config(bg=’black’) snake.geometry(‘750×350′) lbl_menu = Label(snake, text=’SNAKE GAME’, ..

Read more

I am trying to create a speedtest website SO I have a file speedtester.py in src folder- import speedtest st = speedtest.Speedtest() class speed: def __init__(self): st.get_servers() best = st.get_best_server() speed_dict = st.results.dict() self.download = (speed_dict[‘download’]) #/1024/1024:.2f self.upload = (speed_dict[‘upload’]) self.ping = (speed_dict[‘ping’]) self.host_info = (f"{best[‘host’]} located in {best[‘country’]}") self.ip = (speed_dict[‘client’][‘ip’]) def download(self): return ..

Read more

I have a Python script that compares two given excel files and returns (prints) the differences in a dataframe. The upload functions work in the GUI, but the compare button doesn’t seem to work. I guess it has something to do with "self", but I’m not very familiair with that. The compare function on its ..

Read more