World’s first poem written in python
Posted by majutsu on December 23, 2007
# This poem was generated from Python 2.5 using a series of list object operations. # All output (including the output authoring it's own source code) # was sent to the textfile using a virtual compiler during runtime. Wise Remembrances I am not the things I have. I am not the people I love. I am not the labors I do. I am not the perceptions I experience. I am not the thoughts I think. I am not the emotions I feel. I am not the rules I follow. But in this moment . . . The rules I follow become me. The emotions I feel become me. The thoughts I think become me. The perceptions I experience become me. The labors I do become me. The people I love become me. The things I have become me. Rules I follow. Perceptions I experience. Thoughts I think. Labors I do. Things I have. People I love. Emotions I feel. But I will be unhappy if I forget . . . I am not the things I have. I am not the people I love. I am not the labors I do. I am not the perceptions I experience. I am not the thoughts I think. I am not the emotions I feel. I am not the rules I follow. # Like any good poet, I bare my own innards below: import random, sys fileout=open('Wise_remembrances.txt','w') myinnards=open('wiseremembrances.py','r') myinnards_exposed=myinnards.read() sys.stdout=fileout print '# This poem was generated from Python 2.5 using a series of list object operations.' print '# All output (including the output authoring it\'s own source code)' print '# was sent to the textfile using a virtual compiler during runtime.\n' print '\n\nWise Remembrances\n\n' global itemcounter objectlist=[ 'the things I have', 'the people I love', 'the labors I do', 'the perceptions I experience', 'the thoughts I think', 'the emotions I feel', 'the rules I follow'] itemcounter=0 def denunciation(objectlist,itemcounter,grade): for item in objectlist: print itemcounter*'\t'+'I am not '+item+'.\n', itemcounter+=grade return itemcounter def repunct(objectlist): for index in range(0,len(objectlist)): objectlist[index]=objectlist[index].swapcase()+objectlist[index][1:] itemcounter=denunciation(objectlist,itemcounter,1) objectlist.reverse() print '\n'+itemcounter*'\t'+'But in this moment . . .\n' repunct(objectlist) for item in objectlist: itemcounter-=1 print itemcounter*'\t'+item+' become me.' copylist= for item in objectlist: copylist.append(item) random.shuffle(copylist) newlist= for item in copylist: newlist.append(item.upper()+item[5:]+'.') for item in newlist: print '\n',itemcounter*'\t',item, itemcounter+=1 print '\n\n'+itemcounter*'\t'+'But I will be unhappy if I forget . . .\n' objectlist.reverse() repunct(objectlist) itemcounter=denunciation(objectlist,itemcounter,-1) print '\n\n# Like any good poet, I bare my own innards below:\n\n' print myinnards_exposed # This is software that composes a Buddhist sutra "renunciation poem" "on-the-fly". # It further displays it's own source code as above. If you run the code above in a Python compiler, # you will get a different, but similarly-ruled poem. Interestingly, the Artificial Intelligent "author" # reflects on her own process at the end of the poem by displaying her own innards (Including this commentary).