User:Silviolorusso/codeis-concrete-poetry: Difference between revisions

From XPUB & Lens-Based wiki
(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...")
 
No edit summary
Line 5: Line 5:
'''What?'''
'''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.
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.
[[File:codeisconcretepoetry.png]]





Revision as of 18:26, 17 November 2011

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)