the prototype pattern def __str__(self)return "type{ }\ "life{ }\ "speed{ }\ "attack power{ }\ "attack range{ }\ "weapon{ }formatself unit_typeself lifeself speedself attack_powerself attack_rangeself weapon class barracks(object)def build_unit(selfunit_typelevel)if unit_type ="knight"return knight(levelelif unit_type ="archer"return archer(levelif __name__ ="__main__"baracks baracks(knight barracks build_unit("knight" archer barracks build_unit("archer" print("[knight {}format(knight )print("[archer {}format(archer )since the unit data files store the data in predictable orderit makes it very easy to grab the file from disk and then read in the parameters needed to construct the relevant unit the code still delivers the same result as beforebut now we are ready to balance many different unit types and levels in our examplethe import from file looks the same for both the archer and knight classesbut we must keep in mind that we will have units that have to import different parameters from their fileso single import file would be impractical in real-world scenario