Thanks for your thoughful answers, particularly to Yoriz. Actually, I needed a good library with examples which I can customize to use it in my own way and can give different contraints while generating combinations. You people thought I did not even bothered search in Googles by writing simply Python Combinatorics... .... Anyway, you can see the following link if you are interested.