Python -- how to loop over range starting at random point
Question: I have a list of categories (1-4) and I want a loop to iterate over all of
them. But I need to be able to start with a random category and wrap around to
the beginning of the list if my starting point was ahead of list[0].

I was able to do it in a rather verbose way, but I'm wondering if there's a
faster/more elegant way. Here's what I did (and it works):

    
    
    def categorize(self, cat):
    
        cats = [1,2,3,4]
        if cat > 1: 
            ncats = cats[:(cat-1)]
            cats = cats[(cat-1):]
            cats.extend(ncats)
    
        for c in cats:
            pass
    


Answer: 
    from random import randrange
    cats = [1,2,3,4]
    i = randrange(len(cats))
    
    for c in cats[i:]+cats[:i]:
       pass
    

(Changed `choice` to `randrange` as per suggestion)

