Skip to content

Instantly share code, notes, and snippets.

@untitaker
Created April 15, 2013 16:33
Show Gist options
  • Save untitaker/5389383 to your computer and use it in GitHub Desktop.
Save untitaker/5389383 to your computer and use it in GitHub Desktop.
Example for using werkzeug.datastructures.native_itermethods
@native_itermethods(['keys', 'values', 'items', 'foo'])
class AwsumDict(object):
def keys(self): # return iterator
def values(self): # return iterator
def items(self): # return iterator
def foo(self): # return iterator
d = AwsumDict()
## Python 2
# iterator
d.iterkeys()
d.itervalues()
d.iteritems()
d.iterfoo()
# list
d.keys()
d.values()
d.items()
d.foo()
## Python 3
# iterator
d.keys()
d.values()
d.items()
d.foo()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment