next(iterator)
Python built-in function next is used to retrieve next item from an iterator, if it reaches iterator end built-in exception StopIteration is raised.
Example:
list1 = [23, True, 'yes']
myIterator = iter(list1)
#
item = next(myIterator)
print(f"First item is: {item}")
#
item = next(myIterator)
print(f"Item is: {item}")
#
item = next(myIterator)
print(f"Last item is: {item}")
item = next(myIterator)
#Output
First item is: 23
Item is: True
Last item is: yes
Traceback (most recent call last):
File "test.py", line 9, in <module>
item = next(myIterator)
StopIteration
In this example we create iterator myIterator from list1. Then we run next funtion trice using item = next(myIterator) and print item with a f string. myIterator have 3 items, after running trice next function we are at the end of it, once try to run the fourth time next function, StopIteration built-in exception is raised.
class bool(x=False)
The method return a boolean value based on standard "truth testing procedure". Basically this procedure will return True if argument is a number (excepting 0), a string or True itself. It will return False if argument is False, 0 or None, empty. "Truth testing procedure" in python area is comprehensive described here.
Examples:
myarg1=12
print(bool(myarg1))
# output: True
myarg2='string123'
print(bool(myarg2))
# output: True
myarg3=True
print(bool(myarg3))
# output: True
myarg4=False
print(bool(myarg4))
# output: False
myarg5=0
print(bool(myarg5))
# output: False
myarg6=None
print(bool(myarg6))
# output: False
print(bool())
# output: False