mardi 11 août 2020

design pattern for long and dynamic arguments to pass into function

I need to pass a long arguments configuration each time I call

model = create_model(var1, var2, ..., var20)

as I have 20 arguments for the function, where some of them are fixed every time I call it and some of them are dynamic according to the calling scenarios. Now my current solution is to create a config class for the fixed arguments and then I only need to change the dynamic ones each time I call create_model

config = Config(var1, ..., var15)
model = create_model(config, var15, ..., var20)

Is there more efficient method or more pythonic method to apply ?

Aucun commentaire:

Enregistrer un commentaire