I’ve built a parameterized class that dynamically creates parameters based on the user input. Some of you may have already seen it in action here
In a few words:
- when the user instantiate the class, he specify the parameters he needs.
- in the
__init__method I add those parameters by using the command
- finally, those parameters are rendered on the screen with widgets.
Now to my problem: the parameters are attached to the class, not to the instance. Let’s suppose I have the following scenario:
- the user instantiate
c1 = MyClass(five_parameters)where
five_parametersis a list of five parameters which are going to be added to the class. The class will be rendered on the screen and 5 widgets will be shown.
- next, the user instantiate
c2 = MyClass(two_parameters), but when the class is rendered it shows 5 widgets: the two widgets associated to
two_parametersand three remaining widgets associated to the previous instance. This is a killer…
I was looking at the source of the
param module and I didn’t find any “clear/remove” methods. Is there some unofficial way of removing parameters when I create a new instance?