cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

What is the use of the yield keyword in Python? What does it do?

Kaniz
Community Manager
Community Manager
 
2 REPLIES 2

Ryan_Chynoweth
Honored Contributor III

Yield in python similar to the return key word, but instead of returning the output it returns a generated that can be iterated over. When you use the yield key word it will also remember the state of local variables for the next execution.

You can read more about generators in the python reference docs.

Thank you so much @Ryan Chynowethโ€‹ !

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.