def uncertainty(x):
    """Returns the uncertainty of an uncertain quantity.
     This free function allows multiple uncertain quantity types to be supported
     in a generic way."""
    try:
        return x.uncertainty
    except AttributeError:
        try:
            return x.error
        except AttributeError:
            return 0
