def partition(item, filter_):
    inGroup, outGroup = [], []
for n in items:
    if filter_(n):
        inGroup.append(n)
else:
    outGroup.append(n)
return inGroup, outGroup
Python-эквивалент раздела scala