Selecting curve after importing svg using bpy I'm importing an SVG file into my scene using bpy. But after importing, the curve is not selected nor active. Here is wat I am doing:

path = '/path/fo/file/'
file = 'contour.svg'

bpy.ops.import_curve.svg(filepath = path + file)


Can I just assume that the newly imported object is always the last one in the objects array? So that I can grab it like this:

active_object = bpy.context.scene.objects[-1]


Or is there a better way?
You can store the names of the objects before and after importing and find the difference to make sure you have the latest one:

import bpy
C = bpy.context

# Names of all objects before importing the SVG
names_pre_import = set([ o.name for o in C.scene.objects ])

# Import SVG as curve
fp = '/mylocalpath/svgcurve.svg'
bpy.ops.import_curve.svg(filepath = fp)

# Names of all objects after importing the SVG
names_post_import = set([ o.name for o in C.scene.objects ])

# Perform set difference to find the new name and store it
new_object_name = names_post_import.difference( names_pre_import ).pop()

# Reference new object
o = C.scene.objects[ new_object_name ]

# Set as selected and active in Blender 2.7x
o.select = True
C.scene.objects.active = o

# Set as selected and active in Blender 2.8
# o.select_set(True)
# C.view_layer.objects.active = o