def getattributes(nc, exclude=[]):
    # in order not to rely on implementation, provide fallback
    try:
        a = dict(nc._attributes)
    except AttributeError:
        a = dict((k, getattr(nc, k)) for k in dir(nc) if k[0] != '_' and k not in exclude)
    return a