On Thu, 12 Mar 2015 21:40:03 +1300, Gregory Ewing <greg.ew...@canterbury.ac.nz> wrote:
>Mario Figueiredo wrote: > >> A different application, a map editor, needs to also instantiate an >> object of the class Map. But in this case the map needs to either be >> empty (if the user wants to create a new map), or loaded from the >> saved map file (if the user wants to edit an existing map). > >Then you have two functions for creating maps: > >new_empty_map() > >load_map_from_file(filename) > >Both of these can complain if there is already a >Map instance. new_empty_map(width, height, fill=terrain['sea']) load_map_from_file(filename) These would be the most likely signatures for those functions. The first function does not need to perform any of code to do with opening and reading a binary file, verifying an hash for possible file data corruption, filling the map header information and populating the cells. Both functions need to have knowledge of the Map class internals. Is it pythonic to create those functions in the same module of the Map class. Or because of how they have access to some "private" details of the class they should instead be made static methods as a means to signal that much? Map.new() Map.load() -- https://mail.python.org/mailman/listinfo/python-list