This isn't particularly pretty code, but I think it does what you are looking 
for

def printV(varL):
        """ assumes varL is a list of strings, each
                string is the variable NAME of a list
                
                prints the lists named in varL in vertical
                columns 
        """
        def llen(l,L):
                """ l is a length, L is a list
                
                        returns a copy of the list L padded with
                        blanks to a length l
                """
                nL = L[:]
                while len(nL)<l:
                        nL = nL[:]+[' ']
                return nL
        
        # Determine the max length of the lists while
        # printing the list names
        vmax =0
        for name in varL:
                print(name, end='\t')
                vmax = max(vmax, len(globals()[name]))
        print()
        
        # Pad all lists to same (max) length and create
        # a dictionary of lists indexed by var name
        D = {}
        for name in varL:
                D[name] = llen(vmax, globals()[name])
        
        # Print out the list data
        for i in range(vmax):
                for k in D.keys():
                        print(D.get(k)[i], end='\t')
                print()

a=[1,2,4,6]
bad=[2,4,5,6]
craft=[4,5,86,6]
beer=[3,4,6]

my_list = ["a", "bad", "craft", "beer"]
printV(my_list)

-- 
You received this message because you are subscribed to the Google Groups 
"spyder" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/spyderlib.
For more options, visit https://groups.google.com/d/optout.

Reply via email to