creating more than 20 render layers and connect them to different scenes I'm trying to render an animation simultaneously from 32 points of view and integrate the result in a composed animation.

I followed this answer:
How to create a render layer in blender python

and this one:
How to combine renders from multiple cameras

However using:

basescene=bpy.context.screen.scene
for i in Hs:
 for j in Ws:
   bpy.context.screen.scene=basescene
   bpy.ops.scene.new(type='LINK_OBJECTS')       
   newscene=bpy.context.screen.scene
   newscene.name='scene_h_'+ str(i)+'_w_'+str(j)
   new_render_layer =  scene.render.layers.new('rl_h_'+ str(i)+'_w_'+str(j)) 
   newscene.render.layers.active=new_render_layer


Each scene render.layers.active is equal to:

 bpy.data.scenes['scene_h_0_w_4'].render.layers["RenderLayer"]


Or in other words, whatever scene is selected the following is true:

bpy.context.scene.render.layers.active.name == "RenderLayer"


Also the scenes would always miss only the last render layer created

 e.g.   rl_h_0_w_4 not in scene_h_0_w_4 but scene_h_0_w_4 in scene_h_0_w_5


How can I associate each scene to a different render layer and compose them in the final scene?
Actually there was a typo.
The following script creates a new scene and a new render layer making it the active one for that scene

for j in range(N_PERSP_x):
   bpy.context.screen.scene=basescene
   bpy.ops.scene.new(type='LINK_OBJECTS')       
   newscene=bpy.context.screen.scene
   bpy.context.screen.scene.name='scene_h_'+ str(j)+'_w_'+str(j)
   new_render_layer =  newscene.render.layers.new('rl_h_'+ str(j)+'_w_'+str(j))        
   newscene.render.layers.active = new_render_layer


You can check the results with:

for scene in bpy.data.scenes:
   print(scene.name,scene.render.layers.active.name)