get all possible combinations of characters given a string

This will give a result that is more than a permutation, but all possible combinations. An example is when input is 'abc', the output would be: a,ab,abc,ac,acb,b,ba,bac,bc,bca,c,ca,cab,cb,cba


def allperm(inputstr):
    for i in range(len(inputstr)):
        yield(inputstr[i])        
        for s in allperm(inputstr[:i] + inputstr[i+1:]):
            yield(inputstr[i] + s)

code.activestate.com ↗