Here's something pretty complicated to do something simple:
Code:
import string
a = string.join(map(lambda x: chr(x), range(ord('a'), ord('z')+1)),"")
It's the equivalent of:
Code:
a = 'abcdefghijklmnopqrstuvwxyz'
But you gotta admit it's pretty leet!
And for those of you who like Sexylosers and Penny-Arcade, here's a script to check whether there's a new strip or not:
Code:
#!/usr/bin/env python
import httplib
import time
import sys
import string
import os
def pennyarcade():
*year = time.strftime("%Y")
*today = time.strftime("%Y%m%d") + "l.gif"
*strip = "/images/" + year + "/" + today
*h = httplib.HTTPConnection("www.penny-arcade.com", 80)
*h.request("GET", strip)
*response = h.getresponse()
*h.close()
*if response.status == 200:
* *print "THERE'S A NEW Penny-Arcade!!"
*else:
* *print "No new Penny-Arcade... :-("
*config = os.environ["HOME"] + "/.sexylosers"
def sexylosers():
*config = os.environ["HOME"] + "/.sexylosers"
*try:
* *f = open(config, "r")
*except IOError:
* *print "Config file not found!"
* *print "Create it with the following command: echo 134 > ~/.sexylosers"
* *sys.exit(1)
*current_strip = f.readline()
*current_strip = string.join(current_strip.splitlines())
*f.close()
*next_strip = int(current_strip)
*next_strip += 1
*next_strip = str(next_strip)
*h = httplib.HTTPConnection("sexylosers.com", 80)
*h.request("GET", "/?%s" % next_strip)
*response = h.getresponse()
*out = response.read()
*h.close()
*if out != "ERROR! Don't play with the URL, please.\n":
* *print "THERE'S A NEW SEXYLOSER!!! *Episode %s is out!" % next_strip
* *f = open(config, "w")
* *f.writelines(next_strip + "\n")
* *f.close()
*else:
* *print "No new sexylosers... :-("
* *f = open(config, "w")
* *f.writelines(current_strip + "\n")
* *f.close()
pennyarcade()
sexylosers()
Bookmarks