def dms_to_string(d, m, s, decimals=2):
    """Converts degrees, minutes and decimal seconds to well formated coordinate string.
    Example: (41, 24, 12.2)-> 41°24'12.2"

    :param int d: degrees
    :param int m: minutes
    :param float s: decimal seconds
    :param int decimals: second's decimals
    :rtype: str
    """
    return "{d:d}°{m:02d}'{s:0{z}.{c}f}\"".format(d=d, m=m, s=s, z=decimals + 3 if decimals > 0 else 2, c=decimals)