ClassInstance¶
-
MonitorControl.
ClassInstance
(templateClass, subclass, *args, **kwargs)¶ This creates an instance of the specified sub-class
It passes the arguments, if any, to the sub-class initializer. An example of using this function:
>>> IFsw = ClassInstance(Switch, JFW50MS287, lab, "Nx1", 0)
(The last argument is required for the JFW50MS287 to specify which output port it is associated with.)
Notes
Acknowledgment
This approach was recommended by Barzia Tehrani on 2012 Oct 14, 11:36 am: ‘I have seen Instantiate helper methods just to bridge the gap between different languages.’
- Parameters
subclass must provide the template with all the arguments that it (The) –
requires. –
:param : :type : param templateClass : the superclass for this device :param : :type : type templateClass : class :param : :type : param subclass : the implementation of this specific device :param : :type : type subclass : class :param : :type : param args : sequential arguments required to initialize the subclass :param : :type : param kwargs : keyword arguments required to intitialize the subclass