Can't call all() built-in function in IronPython
I'm using the same test code in cPython and IronPython, in cPython it works but I'm getting "name all is not defined" in IronPython in asp.net . I wonder if I have to import some module to use it in IronPython or it's just not available?
lista 开发者_如何学Go= ['a','b']
listados = ['a','b','c']
aca = all(value in listados for value in lista)
The all
and any
functions were added in Python 2.5. Are you using at least version 2.5 of IronPython? If not, it's fairly easy to define a fallback version:
try: all
except NameError:
def all(iterable):
for value in iterable:
if not value: return False
return True
What version of IronPython are you running? all() is a fairly recent Python addition (2.5).
精彩评论