开发者

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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜