2.8 Hide an object with Python?

How do I hide an object in Blender 2.8 using Python? In 2.77+, I just did:

object.hide = True

But the .hide attribute seems to be gone now. How do I do this in 2.8?

Is this what you’re wanting?

bpy.data.objects['Cube'].hide_viewport = True

Yep, that’s exactly what I was looking for. Thanks!

Here’s another one, though.

How do I create a “hide” keyframe using Python? In 2.77+ I did:

tmpObj.keyframe_insert(data_path='hide', frame=scn.frame_start)

Now in 2.8 it’s giving me an error, saying that the property “hide” is not found. Any ideas?

Not sure on this.

looks like you use