You can get it as an iterator using cycle
and islice
from itertools:
A = [1, 2, 3, 4, 2]
B = 3
from itertools import cycle,islice
subIter = zip(A,*(islice(cycle(A),i,None) for i in range(1,B)))
for sub in subIter:
print(sub)
(1, 2, 3)
(2, 3, 4)
(3, 4, 2)
(4, 2, 1)
(2, 1, 2)
Note that this is nothing more than a cute trick, it is not efficient and you should really go with something like ddejohn's solution.
or this variant of it:
[ A[i:i+B]+A[:max(0,i+B-len(A))] for i in range(len(A)) ]
Another solution would be to use deque
from collections:
from collections import deque
from itertools import islice
A = [1, 2, 3, 4, 2]
B = 3
result = [ [*islice(q,q.rotate(-1),B)]
for q in [deque(A)] for _ in q.rotate() or A ]
print(result)
[[1, 2, 3], [2, 3, 4], [3, 4, 2], [4, 2, 1], [2, 1, 2]]