import copy


def merge_args(sub_args, args):
    """
      merges [sub_args] over [args] into [merged_args]:

        For every element that exist in both, the one from [sub_args] is used
    """
    merged_args = copy.copy(args)
    merged_args.subplots = None

    merged_args_dict = merged_args.__dict__
    sub_args_dict = sub_args.__dict__


    for key in sub_args_dict:
        #print( key, sub_args_dict[key] )

        if ( sub_args_dict[key] != None ):
            merged_args_dict[key] = sub_args_dict[key]

    return merged_args