Model = INPUT ( " Choose Module: " ) the class_ = INPUT ( " Please select the type: " ) Money = INPUT ( " Please enter the amount: " ) # Import Module Model = __import__ (Model) # instantiate an object Object = getattr ( Model, class _) (Money) # call the object methods -pay object.pay ()
operation result:
Please select the module: factory_method Please select the type: BenBen Please enter the amount: 100 received a financial payment amount Benben 100