User:Silviolorusso/codeis-concrete-poetry
< User:Silviolorusso
Revision as of 17:23, 17 November 2011 by Silviolorusso (talk | contribs) (Created page with "'''Code is (Concrete) Poetry''' [http://pzwart3.wdka.hro.nl/~slorusso/cgi-bin/codeis-concrete-poetry.cgi Code is (Concrete) Poetry] '''What?''' It's common to hear the expressi...")
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.
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)