Skip to content

Instantly share code, notes, and snippets.

View mxml-barmstrong's full-sized avatar

Brian Armstrong mxml-barmstrong

  • Mixed Media Labs
  • San Francisco, CA
View GitHub Profile
@mxml-barmstrong
mxml-barmstrong / console.txt
Created August 25, 2013 04:39
Python Index, IndexBag, Multidex
In [1]: import index
In [2]: i = index.Multidex(unique_keys=('pk',), common_keys=('name',))
In [3]: class Person(object):
def __init__(self, name):
global last_pk
self.pk = last_pk
last_pk += 1
self.name = name
class SliceDict(dict):
def __getitem__(self, item):
if isinstance(item, slice):
return self.get(item.start, item.stop)
return super(SliceDict, self).__getitem__(item)
>> d = SliceDict()
>> d['a'] = 1
>> d['a']
1