#!/usr/bin/env python
import string
mystr="peter piper picked a peck of pickled peppers"
def gen(s):
words = s.split()
for word in words:
yield s
repl = string.capitalize(word)
s = string.replace(s, word, repl)
yield s
combinations = gen(mystr)
for i in combinations:
print i
Output:
peter piper picked a peck of pickled peppers
Peter piper picked a peck of pickled peppers
Peter piper picked a peck of pickled peppers
Peter Piper picked a peck of pickled peppers
Peter Piper picked a peck of pickled peppers
Peter Piper Picked a peck of pickled peppers
Peter Piper Picked a peck of pickled peppers
Peter Piper Picked A peck of pickled peppers
Peter Piper Picked A peck of pickled peppers
Peter Piper Picked A Peck of pickled peppers
Peter Piper Picked A Peck of pickled peppers
Peter Piper Picked A Peck Of pickled peppers
Peter Piper Picked A Peck Of pickled peppers
Peter Piper Picked A Peck Of Pickled peppers
Peter Piper Picked A Peck Of Pickled peppers
Peter Piper Picked A Peck Of Pickled Peppers
Then it's just something like:
hank@shelob ~/tmp $ python foo.py | while read line; do echo 7z e somefile.7z -p\"$line\"; done
7z e somefile.7z -p"peter piper picked a peck of pickled peppers"
7z e somefile.7z -p"Peter piper picked a peck of pickled peppers"
7z e somefile.7z -p"Peter piper picked a peck of pickled peppers"
7z e somefile.7z -p"Peter Piper picked a peck of pickled peppers"
7z e somefile.7z -p"Peter Piper picked a peck of pickled peppers"
7z e somefile.7z -p"Peter Piper Picked a peck of pickled peppers"
7z e somefile.7z -p"Peter Piper Picked a peck of pickled peppers"
7z e somefile.7z -p"Peter Piper Picked A peck of pickled peppers"
7z e somefile.7z -p"Peter Piper Picked A peck of pickled peppers"
7z e somefile.7z -p"Peter Piper Picked A Peck of pickled peppers"
7z e somefile.7z -p"Peter Piper Picked A Peck of pickled peppers"
7z e somefile.7z -p"Peter Piper Picked A Peck Of pickled peppers"
7z e somefile.7z -p"Peter Piper Picked A Peck Of pickled peppers"
7z e somefile.7z -p"Peter Piper Picked A Peck Of Pickled peppers"
7z e somefile.7z -p"Peter Piper Picked A Peck Of Pickled peppers"
7z e somefile.7z -p"Peter Piper Picked A Peck Of Pickled Peppers"
This doesn't use recursion, so it won't generate the power set of all capitalization combinations, but it should get you started..
I'm going to continue messing around with it to try and get all capitalization combinations - it's a fun problem!