def getPartition(self, seq, p, q):
<EOL>if p<<NUM_LIT:0> or p>=q:<EOL><INDENT>print("<STR_LIT>")<EOL>return<EOL><DEDENT>remainder = len(seq)%q<EOL>basesize = len(seq)//q<EOL>hi = []<EOL>lo = []<EOL>for n in range(q):<EOL><INDENT>if n < remainder:<EOL><INDENT>lo.append(n * (basesize + <NUM_LIT:1>))<EOL>hi.append(lo[-<NUM_LIT:1>] + basesize + <NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>lo.append(n*basesize + remainder)<EOL>hi.append(lo[-<NUM_LIT:1>] + basesize)<EOL><DEDENT><DEDENT>try:<EOL><INDENT>result = seq[lo[p]:hi[p]]<EOL><DEDENT>except TypeError:<EOL><INDENT>result = list(islice(seq, lo[p], hi[p]))<EOL><DEDENT>return result<EOL>
Returns the pth partition of q partitions of seq.