#NEWLINE# def comma_replacement( random , population , parents , offspring , args ) : #NEWLINE# #INDENT# 'Performs "comma" replacement.\n    \n    This function performs "comma" replacement, which means that\n    the entire existing population is replaced by the best\n    population-many elements from the offspring. This function\n    makes the assumption that the size of the offspring is at \n    least as large as the original population. Otherwise, the\n    population size will not be constant.\n    \n    .. Arguments:\n       random -- the random number generator object\n       population -- the population of individuals\n       parents -- the list of parent individuals\n       offspring -- the list of offspring individuals\n       args -- a dictionary of keyword arguments\n       \n    ' #NEWLINE# offspring . sort ( reverse = True ) #NEWLINE# survivors = offspring [ : len ( population ) ] #NEWLINE# return survivors