Source Code Generation Tool
Miklós
nospam at nowhere.hu
Thu Jun 10 17:28:11 EDT 2004
Hi, Infinite Monkeys ;)
Pm
"logistix at cathoderaymission.net" <logistix at cathoderaymission.net> wrote
in message news:3c91a864.0406101223.7c17926e at posting.google.com...
> #
> # 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