# How to insert keyframes using a generator expression

I have a collection of meshes. I want to insert keyframes to all of them. I can obviously write a 'for' loop to do this. However, to keep the code short, I was trying to use a generator expression like this:

(keyframe_insert(data_path = "location", frame = 1) for ob in col.objects[:])

I am not able to add the keyframes this way. All I am getting is a generator object in return:

<generator object <genexpr> at 0x000001754B1CCB48>

Can someone please tell me what I am missing?

• Very much a generic python question. Need to consume the generator. (via formentioned for loop for instance) djangostars.com/blog/… Using a list comprehension instead [i for i in sequence] will create a list of keyframe insert success – batFINGER Jun 17 at 16:49