active - duplicate

Hello to all.
I want to make a script that having 2 objects in the scene, a cube and a plane for example, I can make a duplicate to the object that is not active, assuming that the active object is the plane

import bpy
bpy.context.scene.objects.active = bpy.context.scene.objects[‘Cube’]
bpy.context.object.duplicate()

with this, change the active object (plane X cube), but the duplicate is made to the plane
How can I make the duplicate to cube?
Thanks in advance.

give the docs a read… operator will duplicate selected objects, so something like this will select cube:

import bpy
bpy.context.scene.objects['Cube'].select = True
bpy.ops.object.duplicate()