Neither bpy.context.space_data.display_channel = 5 nor bpy.types.SpaceSequenceEditor(display_channel = 5) seems to be working?
Make sure you have the correct context.
The context area needs to be a video sequencer. Quick console code, find the VSE and set the property from py console.
>>> for i, a in enumerate(C.screen.areas): ... i, a.type ... (0, 'INFO') (1, 'PROPERTIES') (2, 'CONSOLE') (3, 'VIEW_3D') (4, 'SEQUENCE_EDITOR') >>> C.screen.areas.spaces.active.display_channel 0
If your script is invoked via a button or menu in the VSE area use
space = context.space_data
space = context.area.spaces.active
If it is not a VSE area / space then you will get an error (unless another space has a
Each area can have at least one up to a space for each of the editor types. (SEQUENCER, CONSOLE, etc) The one you are seeing is the active one.
area.spaces.active Others you have had active at some stage are stored in
Find all preview VSE's in screen, and set display channel.
previews = [a.spaces.active for a in context.screen.areas if a.type == 'SEQUENCE_EDITOR' and a.spaces.active.view_type == 'PREVIEW'] for s in previews: s.display_channel = 3
bpy.types.SpaceSequenceEditor(display_channel = 5) what is the expectation here?. Instancing from bpy.types classes is very rare, and is mostly done via a new or add method.