🤖📘🍻 Hooray! After 3 years of work, we've finally released a new ebook on design patterns! Check it out »

Prototype Design Pattern in Python

Specify the kinds of objects to create using a prototypical instance,
and create new objects by copying this prototype.

import copy

class Prototype:
    Example class to be copied.


def main():
    prototype = Prototype()
    prototype_copy = copy.deepcopy(prototype)

if __name__ == "__main__":

Code examples

More info, diagrams and examples of the Prototype design pattern you can find on our new partner resource Refactoring.Guru.