import math


def calculate_segment_bearing(shape_obj):
    """Calculate the bearing from a single shape object and return the angle. Assumes projected coords.
    @param - shape object from arcpy for a polyline
    returns - angle - float - angle in degrees (not azimuth)"""
    first_point = shape_obj.firstPoint
    last_point = shape_obj.lastPoint
    first_x = first_point.X
    first_y = first_point.Y
    last_x = last_point.X
    last_y = last_point.Y
    dx = last_x - first_x
    dy = last_y - first_y
    rads = math.atan2(dy, dx) # Relative to North
    angle = math.degrees(rads)
    return angle