Source Code Generation Tool

Discussion in 'Python' started by logistix at cathoderaymission.net, Jun 10, 2004.

  1. #
    # 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
    logistix at cathoderaymission.net, Jun 10, 2004
    #1
    1. Advertising

  2. logistix at cathoderaymission.net

    Miklós Guest

    Hi, Infinite Monkeys ;)

    Pm

    "logistix at cathoderaymission.net" <> wrote
    in message news:...
    > #
    > # 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
    Miklós, Jun 10, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David M. Siegel
    Replies:
    0
    Views:
    338
    David M. Siegel
    Oct 20, 2003
  2. f
    Replies:
    3
    Views:
    398
  3. bill turner
    Replies:
    2
    Views:
    1,106
    bill turner
    Jul 19, 2005
  4. Stefan Behnel
    Replies:
    3
    Views:
    469
  5. John W. Long

    HTML Generation (Next Generation CGI)

    John W. Long, Nov 22, 2003, in forum: Ruby
    Replies:
    4
    Views:
    317
    John W. Long
    Nov 24, 2003
Loading...

Share This Page