concept any() in category python

appears as: ny()
Tiny Python Projects: Learn coding and testing with puzzles and games

This is an excerpt from Manning's book Tiny Python Projects: Learn coding and testing with puzzles and games.

Let’s take a moment to appreciate the any() function as it’s one of my favorites. The preceding code uses a map() to check if each of the vowels exists in the portion of the word before the “ing” ending:

Most of the validation can be handled by using argparse effectively. Both the --player and --cell options can be handled by the choices option. It’s worth taking time to appreciate the use of any() and all() in this code:

if any([args.player, args.cell]) and not all([args.player, args.cell]):
    parser.error('Must provide both --player and --cell')

We can play with these functions in the REPL. The any() function is the same as using or in between Boolean values: