How to change View3DShading type in 2.8?


#1

I want to change the shading type to MATERIAL: https://i.imgur.com/U58tSmu.png
How can I do this with a script?
Thanks!

Edit: I figured it out:

for area in context.screen.areas:  # iterate through areas in current screen
    if area.type == 'VIEW_3D':
        for space in area.spaces:  # iterate through spaces in current VIEW_3D area
            if space.type == 'VIEW_3D':  # check if space is a 3D view
                space.shading.type = 'MATERIAL'  # set the viewport shading to material