Last active
October 1, 2015 01:28
-
-
Save adrianp/1894953 to your computer and use it in GitHub Desktop.
Comparing a list with a function in Python
This file contains 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
"""Some Python code to illustrate the 'issue' noticed in JavaScript here: | |
http://stackoverflow.com/questions/9381321/a-function-is-larger-than-an-array | |
This will work on Python 2.x; in Python 3.x you would get: | |
TypeError: unorderable types: list() > function() | |
""" | |
l1 = [] | |
def f(): | |
return 0 | |
l2 = [] | |
print l1 > f # True | |
print f > l1 # False | |
print str(l1) > str(f) # True, same as line 15 | |
print str(f) > str(l1) # False, same as line 16 | |
print l2 > f # True | |
print f > l2 # False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment