Can't seem to apply smooth shading

I’m new to using Python in Blender and have been trying to import a terrain from images. This has gone well so far, but when I try to apply smooth shading it doesn’t seem to show up. See the screenshot, the result of running the script.


Do you need to ‘select’ the object before smoothing?

Thanks, that seemed to work, had to look up how to correctly select the object first. Is this the best way?

    ob = bpy.data.objects.get('Terrain')
    ob.select = True
    bpy.context.scene.objects.active = ob    
    bpy.ops.object.shade_smooth()

if you wanna avoid using an operator and setting an object for this beforehand, you can use:

ob = bpy.data.objects.get('Terrain')
for poly in ob.data.polygons:
    poly.use_smooth = True

Same result.