yield with recursive function in python <p>I am trying to create a generator for permutation purpose.I know there are other ways to do that in python.But this is for somthing else. But I am not able to yield the values .Can you help?</p> <pre><code>def perm(s,p=0,ii=0): l=len(s) s=list(s) if(l==1): print ''.join(s) elif((l-p)==2): yield ''.join(s) yield ''.join([''.join(s[:-2]),s[-1],s[-2]]) #print ''.join(s) #print ''.join([''.join(s[:-2]),s[-1],s[-2]]) else: for i in range(p,l): tmp=s[p] s[p]=s[i] s[i]=tmp perm(s,p+1,ii) </code></pre>