Change tile grid shape I'm trying to change the tile_grid_shape in the UV Editor window located in the UV Editing workspace. The problem is that the only way to do this that I found is bpy.context.... but using context is not an option in my case since the context is actually a different window. If I change the context to be UV Editor it changes the tiles in that window and not in the one in the UV Editing workspace.
This is what I tried with no success:
for area in bpy.data.screens['UV Editing'].areas:
    if area.type == 'IMAGE_EDITOR':
        area.type.uv_editor.tile_grid_shape[0] = 3

In this case I'm getting an error that 'str' object has no attribute 'uv_editor'
I also tried this:
bpy.data.screens['UV Editing'].uv_editor.tile_grid_shape[0] = 3

Still no success though. I'm getting an error that 'screen' object has no attribute 'uv_editor'
I got it from here, but it doesn't work. I guess they changed it and didn't correct it here.

I also know of one other method with context override where you copy the context and do whatever you want in the new one, but the problem with that is that you can't delete the newly created context and when using it in a big batch it makes thousands of context copies and takes a lot of memory that you can't clear unless you restart Blender.
So does anyone have any idea how to do this thing?
Is a property of the UV editor space of the Image editor space.
Same deal as How to change View3DOverlay.show_stats?
The property is a member of the UV editor space. https://docs.blender.org/api/current/bpy.types.SpaceUVEditor.html#bpy.types.SpaceUVEditor.tile_grid_shape
following references will see that the UV editor is available from the Image editor
bpy.types.SpaceImageEditor.uv_editor

Test in python console.
&gt;&gt;&gt; for i, a in enumerate(C.screen.areas):
...     i, a.type
...     
(0, 'PROPERTIES')
(1, 'OUTLINER')
(2, 'IMAGE_EDITOR')
(3, 'VIEW_3D')
(4, 'CONSOLE')

&gt;&gt;&gt; space = C.screen.areas[2].spaces.active
&gt;&gt;&gt; space
bpy.data.screens['UV Editing']...SpaceImageEditor

&gt;&gt;&gt; space.uv_editor
bpy.data.screens['UV Editing'].uv_editor
# Wrongly represents itself.

&gt;&gt;&gt; type(space.uv_editor)
&lt;class 'bpy.types.SpaceUVEditor'&gt;

&gt;&gt;&gt; space.uv_editor.tile_grid_shape[:]
(1, 1)

&gt;&gt;&gt; space.uv_editor.tile_grid_shape = (2, 1)

Re error area.type is a string (see line above) and has no tile_grid_shape property.