jasily/utils/__init__.py
def get_parent(obj):
    '''
    get parent from obj.
    '''
    names = obj.__qualname__.split('.')[:-1]
    if '<locals>' in names: # locals function
        raise ValueError('cannot get parent from locals object.')
    module = sys.modules[obj.__module__]
    parent = module
    while names:
        parent = getattr(parent, names.pop(0))
    return parent
def get_parent(obj):
    '''
    get parent from obj.
    '''
    names = obj.__qualname__.split('.')[:-1]
    if '<locals>' in names: # locals function
        raise ValueError('cannot get parent from locals object.')
    module = sys.modules[obj.__module__]
    parent = module
    while names:
        parent = getattr(parent, names.pop(0))
    return parent
def get_parent ( obj ) : names = obj . __qualname__ . split ( '.' ) [ : - 1 ] if '<locals>' in names : # locals function raise ValueError ( 'cannot get parent from locals object.' ) module = sys . modules [ obj . __module__ ] parent = module while names : parent = getattr ( parent , names . pop ( 0 ) ) return parent
get parent from obj.
get parent from obj .