#NEWLINE# def __init__( self , node_factory , width , height , x_wrap = WRAP_ERROR , y_wrap = WRAP_ERROR ) : #NEWLINE# #INDENT# 'Create a grid object.\n\n        node_factory -- Callable that takes the x and y coordinate of the node\n        and returns a node object. x_wrap and y_wrap parameters should be\n        one of (WRAP_REPEAT, WRAP_CLAMP, WRAP_ERROR).\n\n        width -- Width of the grid.\n        height -- Height of the grid.\n        x_wrap -- How to handle out of range x coordinates\n        y_wrap -- How to handle out of range y coordinates\n\n        ' #NEWLINE# self . node_factory = node_factory #NEWLINE# self . width = width #NEWLINE# self . height = height #NEWLINE# self . nodes = [ [ node_factory ( x , y ) for x in range ( width ) ] for y in range ( height ) ] #NEWLINE# self . _x_wrap = x_wrap #NEWLINE# self . _y_wrap = y_wrap #NEWLINE# self . _wrap_functions = [ self . _make_wrap ( self . _x_wrap , self . width ) , self . _make_wrap ( self . _y_wrap , self . height ) ]