This method returns a list of tuples containing MEMNAME, MEMTYPE of members in the library of memtype data or view

        If you would like a Pandas dataframe returned instead of a list, specify results='pandas'

def list_tables(self, libref, results: str = 'list'):
        """
        This method returns a list of tuples containing MEMNAME, MEMTYPE of members in the library of memtype data or view

        If you would like a Pandas dataframe returned instead of a list, specify results='pandas'
        """

        if not self.nosub:
           ll = self.submit("%put LIBREF_EXISTS=%sysfunc(libref("+libref+"));")

           exists = ll['LOG'].rpartition('LIBREF_EXISTS=')[2].split('\n')[0]

           if exists != '0':
              print('Libref provided is not assigned')
              return None

        code = """
        proc datasets dd=librefx nodetails nolist noprint;
           contents memtype=(data view) nodetails 
              dir out=work._saspy_lib_list(keep=memname memtype) data=_all_ noprint;
        run;
        
        proc sql;
           create table work._saspy_lib_list as select distinct * from work._saspy_lib_list;
        quit;
        """.replace('librefx', libref)

        if self.nosub:
            print(code)
            return None
        else:
           ll  = self.submit(code, results='text')

        if results != 'list':
           res = self.sd2df('_saspy_lib_list', 'work')
           return res
           
        code = """
        data _null_;
           set work._saspy_lib_list end=last curobs=first;
           if first EQ 1 then
              put 'MEMSTART';
           put 'MEMNAME=' memname;
           put 'MEMTYPE=' memtype;
           if last then
              put 'MEMEND';
        run;
        """

        ll  = self.submit(code, results='text')

        res = []
        log = ll['LOG'].rpartition('MEMEND')[0].rpartition('MEMSTART')
                                                                                  
        for i in range(log[2].count('MEMNAME')):                                    
           log = log[2].partition('MEMNAME=')[2].partition('\n')                    
           key = log[0]                                                           
           log = log[2].partition('MEMTYPE=')[2].partition('\n')                     
           val = log[0]                                                           
           res.append(tuple((key, val)))                                                         
                                                                                  
        return res