Skip to content

Instantly share code, notes, and snippets.

@gregglind
Created November 19, 2010 04:18
Show Gist options
  • Save gregglind/706115 to your computer and use it in GitHub Desktop.
Save gregglind/706115 to your computer and use it in GitHub Desktop.
Showing some raw python, if there were no classes...
## python without classes?
def newlist(items):
def in_(item):
return item in items
def index(a):
return items.index(a)
def pretty():
for x in items:
print x
# python needs the symbols defined
# before we reference them
methods = {
'in_': in_,
'index': index,
'pretty': pretty,
}
return methods
L = newlist(['a','b','c','d'])
assert L['in_']('a') == True
assert L['index']('c') == 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment