lang/python/ PythonRecipesListManipulation1
== Chunks This is sometime I keep looking up nice ways for. This in is from [https://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks stackoverflow]. {{c
def chunks(lst, n): """Yield successive n-sized chunks from lst.""" for i in range(0, len(lst), n): yield lst[i:i + n] }} == Get lines of file {{c
as this stands, this removes all \r characters
to convert from windows line endings to unix
removes any trailing blank lines, then splits into lines
def flines(filename): return open(filename).read().replace("\r","").rstrip("\n").split("\n") }}%TIME=1632682084