Last active
August 29, 2015 14:01
-
-
Save gferreira/55707269071ad330e292 to your computer and use it in GitHub Desktop.
The Zen of Python, in DrawBot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# how to get the text from Zen of Python | |
# and set it on a page with DrawBot | |
import this | |
# reload(this) | |
# this prints the ZOP in the output window | |
# but how can we get the text string and save it into a variable? | |
# let's see what's inside `this` | |
# print dir(this) | |
# hmm. what is this stuff? | |
# print this.c # ? | |
# print this.d # this looks like a substition cypher | |
# print this.s # this looks like the ZOP, but the text is cyphered | |
# print this.i # ? | |
# let's try to apply the substituion cypher to the text | |
zen = '' | |
for char in this.s: | |
if this.d.has_key(char): | |
zen += this.d[char] | |
else: | |
zen += char | |
print zen | |
# aha, it works! | |
# now we can set it on the page | |
size(210, 297) | |
lineHeight(7) | |
fontSize(4) | |
textBox(zen, (20, 20, width()-40, height()-40)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment