samedi 15 mai 2021

Call python method with self parameter

He guys, I'm new with Python and now I'm studying Object oriented with py. So, in my case I have a class Founds with one atributte (it will increase later), and I'm modeling to right standards. But when I call this method from another class (Main), it throws:

TypeError: val() missing 1 required positional argument: 'fundos' 

My main class where I call, instantiate this method. I prefer to use objects, because system will grow up in a few days in complexity. My main:

class Main(FlaskForm):   

series = None 
fundos = fundos()

@app.route('/resultado', methods=['GET','POST'])
def resultado():
    titulo = "Retorno da pesquisa"
   
    valuation = request.form.getlist("fundo_select")
    nomefundo = request.form.get("fii")
    fundoss = any
    fundoss = nomefundo.split(',')  
        
    **series = fundos.val(fundoss)**            
    

My founds class:

class Fundos(object):  
# Atribuindo na classe como Nada
lista_fiis=None;

# Array de atributos da classe, inicializando
def __init__(self):
    # Inicializando como array
    self.lista_fiis=[]


# Pega fundos selecionados
# Gera o relatório no excel
def val(self, fundos):
    info_fii={}

Aucun commentaire:

Enregistrer un commentaire