Any Of

ASnake Documentation

Table Of Contents

Summary:

The any/all function is Python checks a iterable if any, or all, of a iterable meet a condition. ASnake has a syntax alias as a shortcut for this function.

Syntax any:

Aliases:

  1. any
  2. any of

any with an optional of must be proceeded with a iterable, then are with a value to match after. This will check if any of the iterables are the provided value.

if any of 1,1,2 are equal then "yep"
# result: yep

if any of "abcdefg" are 'h' do 'ha'
else 'ah'
# result: ah

b = [1,7,2]
if any of b are > 6 then "above 6"
# result: above 6

Syntax all:

Aliases:

  1. all
  2. all of
  3. each
  4. each of

Has the same syntax rules as any, except checks a match for every element of the iterable.

if all of 2,2,2 are equal do "everything is 2"
# result: everything is 2

Syntax are:

Should come after any or all's iterable, and the check after. Valid examples are comparison operators with a value after, a literal or value containing a literal, and a bare equal. not is also allowed.

Examples:

b = [1,2,3,4]
if all of 1,2,3 are in b do 'yes'
# result: yes

if any of True,True,False are not True do 'not all true'
# result: not all true

if any of ("safe","safe","unsafe") are 'unsafe' do 'unsafe!'  
# result: unsafe

if all of [21,12,62,93] are > 11 do 'great'
# result: great

if all of 2,2,2 are equal do "everything is 2"
# result: everything is 2

Syntax arent:

Aliases:

  1. arent
  2. aren't
  3. are not

Same usage as are, except it negates. Checking for False instead of True (or True, if the value to be checked was False). When passed a comparison, it will attempt to do the opposite comparison (> instead of < for example).

Examples:

if any of 'bba' arent 'b' do 'ONLY B!'
# result: ONLY B!

if all of 43,29,72 arent > 999 do 'NOT HIGH ENOUGH!'
# result: NOT HIGH ENOUGH!

if all of 1,2,3 arent not equal then "um ok"
else 'Ow, my brain.'
# result: Ow, my brain.
Scroll to top