Python 101: Changing the behavior of the "range" function


We create an custom iterator function that we will use with a "for" loop:


We use it as below:


The "yield" function acts as a return function but it doesn't completely  exit the function - the control is not handed back completely to the caller of the function - and the next instruction in the function is run:

Comments

Popular posts from this blog

Istio 101 : How Istio ServiceEntry relates to Kubernetes Services and Endpoints

Istio 101 : - Loadbalancing, attempts and retries - DestinationRule, VirtualService - -

Istio 101 : - Traffic routing - Virtual services and Destination rules - -