python design patterns factorypython pattern the factory pattern comes under the creational patterns list category it provides one of the best ways to create an object in factory patternobjects are created without exposing the logic to client and referring to the newly created object using common interface factory patterns are implemented in python using factory method when user calls method such that we pass in string and the return value as new object is implemented through factory method the type of object used in factory method is determined by string which is passed through method in the example belowevery method includes object as parameterwhich is implemented through factory method how to implement factory patternlet us now see how to implement factory pattern class button(object)html "def get_html(self)return self html class image(button)html "class input(button)html "class flash(button)html "class buttonfactory()def create_button(selftyp)targetclass typ capitalize(return globals()[targetclass](button_obj buttonfactory(