0

Context

There is class 'A' which needs a lot of parameters. And there are classes B,C,D which depends D->C->B->A way. I have to set parameters for A while initializing D which would be passed on to C then to B, A. Now the problem is that the list of parameters is so big that it would be pain to pass each of it as argument in constructor. So instead I created a dictionary to pass it on by.

Question

In this case, is passing parameters with dictionary OK? If not, are there other way to solve this?

Inyoung Kim 김인영
  • 1,434
  • 1
  • 17
  • 38

2 Answers2

1

Yes. This is pretty much the use case for **kwargs.

kthy
  • 827
  • 10
  • 27
0

just inherit all the classes with class A and then pass a parameter in the dictionary...

Mohit Verma
  • 53
  • 1
  • 1
  • 10