Skip to content

Instantly share code, notes, and snippets.

@khajavi
Created May 22, 2013 12:22
Show Gist options
  • Save khajavi/5627147 to your computer and use it in GitHub Desktop.
Save khajavi/5627147 to your computer and use it in GitHub Desktop.
redirect io to file
#!/usr/bin/env python3
import sys
orig_stdout = sys.stdout
f = open('out.txt', 'w')
sys.stdout = f
alphabets = "qwertyuiopasdfghjklzxcvbnm"
codes = [ x + y + z for x in alphabets for y in alphabets for z in alphabets ]
for item in codes:
print( item )
sys.stdout = orig_stdout
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment