Created
April 15, 2013 16:33
-
-
Save untitaker/5389383 to your computer and use it in GitHub Desktop.
Example for using werkzeug.datastructures.native_itermethods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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