Skip to content

Instantly share code, notes, and snippets.

@adaptives
adaptives / app.py
Created October 6, 2011 17:13
LPTHW Exercise 52
import web
from gothonweb import map
urls = (
'/game', 'GameEngine',
'/', 'Index',
)
app = web.application(urls, globals())
@adaptives
adaptives / app.py
Created October 5, 2011 10:20
LPTHW Exercise 51 - Templates
import web
urls = (
'/hello', 'Index'
)
app = web.application(urls, globals())
render = web.template.render('templates/', base="layout")
@adaptives
adaptives / app.py
Created October 5, 2011 10:09
LPTHW Exercise 51 - Form Data
#This app.py handles POST data from the hello_form
import web
urls = (
'/hello', 'Index'
)
app = web.application(urls, globals())
@adaptives
adaptives / app.py
Created October 5, 2011 09:42
LPTHW Exercise 51
import web
urls = (
'/hello', 'Index'
)
app = web.application(urls, globals())
render = web.template.render('templates/')
@adaptives
adaptives / app.py
Created October 5, 2011 07:46
LPTHW Exercise 50
import web
urls = (
'/', 'index'
)
app = web.application(urls, globals())
render = web.template.render('templates')
class index:
@adaptives
adaptives / lexicon.py
Created October 4, 2011 11:54
LPTHW Exercise 49
class LexiconC(object):
def __init__(self):
#constants
# TODO: Can we make these as constants so they can be accessed from out side the class with just the class name ?
self.C_DIRECTION_WORDS = "direction"
self.C_VERBS = "verb"
self.C_STOP_WORDS = "stop"
self.C_NOUNS = "noun"
self.C_NUMBER = "number"
@adaptives
adaptives / lexicon.py
Created October 4, 2011 08:58
LPTHW Exercise 48
class LexiconC(object):
def __init__(self):
#constants
# TODO: Can we make these as constants so they can be accessed from out side the class with just the class name ?
self.C_DIRECTION_WORDS = "direction"
self.C_VERBS = "verb"
self.C_STOP_WORDS = "stop"
self.C_NOUNS = "noun"
self.C_NUMBER = "number"
self.C_ERROR = "error"
@adaptives
adaptives / game.py
Created October 4, 2011 06:24
LPTHW Exercise 47 - Unit Testing With nose
class Room(object):
def __init__(self, name, description):
self.name = name
self.description = description
self.paths = {}
def go(self, direction):
return self.paths.get(direction, None)
@adaptives
adaptives / pypom.py
Created October 4, 2011 05:44
PyPomodoro Executable Script
#! python
from pypomodoro import pomodoro
from sys import argv
script, task, time_period = argv
pomodoro.start(task, time_period)
@adaptives
adaptives / ex45.py
Created October 1, 2011 10:34
LPTHW Exercise 45
## Animal is-a object (yes, sort of confusing) look at the extra credit
class Animal(object):
pass
## is-a Animal
class Dog(Animal):
def __init__(self, name):
## has-a name
self.name = name