Workaround ply slicing bug

An old bug in ply renders slicing impossible in Python 3, so
instead just collect the necessary elements in a list.