Problems with Python syntax I am a more or less skilled Python user in Maya for quite some time and wanted to look into Python within Blender (Version: 2.79).

This is my code:

def posRotSclObj():
sel = bpy.context.selected_objects
sel2 = sel[0]
sel1 = sel[1]
print(sel1)
print(sel2)

pos1 = sel1.location
rot1 = sel1.rotation_euler
scl1 = sel1.scale
print (scl1)

pos2 = sel2.delta_location

sel2.location = (pos1[0], pos1[1], pos1[2])
sel2.rotation_euler = (rot1[0], rot1[1], rot1[2])
sel2.scale = (scl1[0], scl1[1], scl1[2])

posRotSclObj()


I have 3 problems right now:


When I define my selection by sel = bpy.context.selected_objects then sel[0] is the second object I have selected and sel[1] the first...that's pretty counterintuitive, especially because it was the other way around in Maya. Is this right?
print sel would work in Maya but Blender needs brackets around my variable: print (sel). Why is there difference in syntax?
When I indent beginning from the line after def except for the last where I call my function and paste it into the python console within Blender it gives me indentation errors on every line that has one indent.
As we can see from https://knowledge.autodesk.com/support/maya/learn-explore/caas/CloudHelp/cloudhelp/2018/ENU/Maya-Scripting/files/GUID-C0F27A50-3DD6-454C-A4D1-9E3C44B3C990-htm.html :


  Maya installs Python with your Maya installation. Maya uses Python
  version 2.7.11 on all supported platforms. 


Maya uses an old legacy version of Python while Blender uses Python version 3.5.3. There are syntax differences between these versions and brackets is one of them. I am not sure about indentation in 2.7.11, but in the version that comes with Blender it is 4 spaces. 

The sequence in which the selected objects are stored is not something that can be intuitive in my opinion and there is no logical reason one way is better than the other, however if you wish to reverse the order you can do so with Python very easily:

sel = bpy.context.selected_objects[::-1]