User:Silviolorusso/codeis-concrete-poetry

From XPUB & Lens-Based wiki

Code is (Concrete) Poetry

Code is (Concrete) Poetry

What? It's common to hear the expression: "Code is Poetry". Connecting it to Concrete Poetry of the '60s, I made a generator that keeps only the punctuation of the code that you paste, revealing a new visual layer of it.

Codeisconcretepoetry.png


Code

#!/usr/bin/env python
#-*- coding:utf-8 -*-
 
import cgi
import cgitb; cgitb.enable()
 
query = cgi.FieldStorage()
text = query.getvalue("text", "")
 
## Alter text here
import re
text = re.sub(r"\w", r" ", text)
 
print "Content-type: text/html"
print
print """
<html>
<head>
<style>
textarea {{
    font-size: 10px;
    font-style: bold;
    width: 100%;
    height: 380px;  
    background:black;
    color: white;  
    border:none;  
}}
</style>
</head>
<body>
<form action="">
    <textarea name="text">{0}</textarea>
<span style="font-family: Arial; font-size:10px;">Paste Some Code and</span> <input style="font-family: Arial; font-size:10px;" type="submit" value="Generate Concrete Poetry">
</form>
</body>
</html>
""".format(text)