0

how to call a parameter from the def init method in @staticmethod ?

def calc(self): pass @classmethod def update(cls): cls.calc() TypeError: calc() missing 1 required positional argument: 'self'

14th Aug 2021, 7:06 PM
Alisa Zaiceva
6 Answers
+ 2
Is that the complete code? Shouldn't there be a class? (and a static method is not the same as a class method)
14th Aug 2021, 7:28 PM
Lisa
Lisa - avatar
+ 1
Something like this ? class Student(): def __init__(self,n,a): self.name=n self.age=a @staticmethod def About_me(obj): print(f"My name is {a.name}") a=Student("xyz",100) Student.About_me(a)
14th Aug 2021, 8:51 PM
Abhay
Abhay - avatar
0
no, this is not the full code. the full code is too large, but this is the essence of the error
14th Aug 2021, 8:25 PM
Alisa Zaiceva
0
Full code: import random import os import json class Basic_params: class_object = f'{name}.json' def init(self): self.temp = {} self.params = { 'name': 'name', 'basic_params': { 'basic_strength': 0, 'basic_agility': 0, 'basic_intelligence': 0, 'basic_stamina': 0, 'basic_damage': 0, 'basic_armor': 0, 'basic_crit': 0, 'basic_chance_crit': 0, 'basic_magic_damage': 0, 'basic_hp': 0, 'basic_mana': 0, 'basic_hp_regen': 0, 'basic_mana_regen': 0, 'basic_move_speed': 0, 'basic_magic_resist': 0, 'basic_attack_speed': 0, 'basic_chance_dodge': 0, 'basic_luck': 0 } } self.temp0 = {} self.temp0.update({'0': self.params}) self.my_id = self.get_nex
14th Aug 2021, 8:26 PM
Alisa Zaiceva
0
from Basic_params import Basic_params import json import random class Atrribut(Basic_params): def init(self): super().init() self.bp = self.params['basic_params'] self.atrribut = {} def calc(self): self.atrribut = { 'hp': { 'max_hp': int(self.bp['basic_hp']) + int(self.bp['basic_stamina']) * 10, 'current_hp': int(self.bp['basic_hp']) + int(self.bp['basic_stamina']) * 10, 'regen_hp': int(self.bp['basic_hp_regen']) + int(self.bp['basic_stamina']) / 10 }, 'mana': { 'max_mana': int(self.bp['basic_mana']) + int(self.bp['basic_intelligence']) * 10, 'current_mana': int(self.bp['basic_mana']) + int(self.bp['basic_intelligence']) * 10, 'current_regen_mana': int(self.bp['basic_mana_regen']) + int(self.bp['basic_intelligence']) / 10 }, 'damage': { 'current_damage': int(self.bp['basic_damage']) + int(self.bp[
14th Aug 2021, 8:26 PM
Alisa Zaiceva
0
thank you but I have already rewritten the code
15th Aug 2021, 12:41 AM
Alisa Zaiceva