Source Code Generation Tool

logistix at cathoderaymission.net logistix at cathoderaymission.net
Thu Jun 10 16:23:38 EDT 2004


#
# libraryOfBabel.py
# 
# This is a general purpose source code generation tool.
#
# It generates any code you may require for python, perl, rexx,
#       C, C++, befunge, ADA, ruby and other programming languages
#
# It will generate the source code for Python 3000
#
# It is also capable of generating the complete works of 
#	William Shakespeare, Friedrich Nietzsche, 
#	and Raymond Chandler
#

import sys

symbols = [chr(x) for x in range(128)]
symbols.remove(chr(7))

def indexToSymbol(index):
    try:
        return symbols[index]
    except:
        raise Exception("invalid index %i" % index)

def symbolToIndex(symbol):
    try:
        return symbols.index(symbol)
    except:
        raise Exception("Invalid Symbol '%s'" % symbol)
    
def generateDocument(number):
    while number:
        div,mod = number / len(symbols), number % len(symbols)
        sys.stdout.write(indexToSymbol(mod))
        number = div

i = 1401448258002517817034703038066348000649199218

while 1:
    print '=' * 79
    print 'DOCUMENT ID ', i
    print '=' * 79
    generateDocument(i)
    i += 1



More information about the Python-list mailing list