View extents (scale to fit render window)
dimensions is a property of object so you access it with object.dimensions not as a call to an operator. As a list of 3 values you can get the largest one with max(object.dimensions), or you can look at each value with object.dimensions.x

import bpy

obj = bpy.context.active_object

maxDimension = 5.0

scaleFactor = maxDimension / max(obj.dimensions)

obj.scale = (scaleFactor,scaleFactor,scaleFactor)


This assumes you are starting with a scale of 1.0. If not then you may want to use bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) before starting.