Doubts about python classes and attributes

Asked

Viewed 40 times

1

I am creating a program in python and I have some doubts about the declaration of classes and attributes.

I have two class files, one generated named dosps.py and another kpi.py

Inside these files, I have the Generated and Kpi classes The Generated class imports the attributes of the Kpi class.

import random

#import numpy

from kpi import Kpi

class Geradadosps:

def __init__(self,nome_arquivo,identificador,habilidade):
    self.nome_arquivo = nome_arquivo
    self.identificador = identificador
    self.habilidade = habilidade
    self.qnt_historicos = 10
    self.qnt_kpi = 4
    self.kpi
pass

def Gerar_historico(self,kpi_identificador):
    kpi_historico = []
    for i in range(self.qnt_historico):
        kpi_historico = kpi.historico.append(round(random.random(),2))
    self.kpi = Kpi(kpi_identificador,kpi_historico)

My question is. How do I assign the kpi object into the generated class self.kpi attribute?

You’re right about this assignment?

kpi.py class information

class Kpi:

def __init__(self,identificador, historico):
    self.identificador = identificador
    self.qnt_historicos = 10
    self.historico = historico
pass

@property
def historico(self):
     return self._historico

@historico.setter
def historico(self, historico):
     self._historico= historico   
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.