自 Python 2.5 以後,內建 all() 與 any() 可用來判別选代子是否存有任何值為真或假。 以碼演義: {{{ #!python >>> GoodSoulsComeToRest = ['Strangefolk', ('Monkey', 'Happyfolk') ] >>> all( GoodSoulsComeToRest ) True >>> GoodSoulsComeToRest = [ 0, ('Monkey', 'as 0 appear in here...') ] >>> all( GoodSoulsComeToRest ) False >>> any( GoodSoulsComeToRest ) # Monkey strings still there True >>> black = 0,0,0,0,0,0 >>> ManInBlack = [man for man in black] # Just a 0-list clone >>> any( ManInBlack ) False >>> all( ManInBlack ) # Since no any, of course not all False }}} [[http://amix.dk/blog/viewEntry/19303|amix.dk - Python 2.5: Using any function]] [[http://www.artima.com/weblogs/viewpost.jsp?thread=98196|The fate of reduce() in Python 3000]] [[http://docs.python.org/whatsnew/other-lang.html|Other Language Changes]] in Python 2.5