jeudi 29 avril 2021

Structure of a function altered by if statement Python

There is the function a could either be in the form of client.LinearKline.LinearKline_get() or in the form of client.Kline.Kline_get(). a and b, (first_run) however the a,(second_run) does not work. c just combines a and b and is simplifies it. My previous post: issue . How would I be able to make 'c' work with getattr.

choice= 1

if choice == 1:
    a = "LinearKline"
    b = "LinearKline_get"
    c = "LinearKline.LinearKline_get"
else:
    a = "Kline"
    b = "Kline_get"
    c = "Kline.Kline_get"

first_run =getattr(getattr(client, a), b)()
second_run= getattr(client, c)()

Aucun commentaire:

Enregistrer un commentaire