How to understand that python uses for in to subscribe to messages

how do you understand that python uses for in to subscribe to messages?

I used to work on the front end, and event subscriptions are written in this way, which is easy to understand.

eventBus.on("close", function(e){
 console.log(e)
})

recently, I learned that python, uses redis and kafka to do some message queuing, and I feel that I can"t understand the subscription of messages. I always thought that for in is just for looping, such as traversing items in any sequence, such as lists, tuples, and so on. so I can"t understand how python for in can listen for messages

after Google, I didn"t find the relevant explanation, only saw the relevant usage. It seems that no one is confused about this usage. I hope those who understand can explain it. Thank you.

// redis
import redis
...
for msg in sub.listen():
    print(msg)
// kafka
from kafka import KafkaConsumer
...
for message in consumer:
    print(message)
Apr.01,2021

Let me give you a hint to learn about iterators and generators in python, and async and synergy in python3 by the way

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38795-2c123.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38795-2c123.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?