#13131: Make a top-level table/Table function
----------------------------------+-----------------------------------------
       Reporter:  kcrisman        |         Owner:  was                         
    
           Type:  enhancement     |        Status:  needs_review                
    
       Priority:  major           |     Milestone:  sage-5.9                    
    
      Component:  user interface  |    Resolution:                              
    
       Keywords:                  |   Work issues:                              
    
Report Upstream:  N/A             |     Reviewers:  Jason Grout, Karl-Dieter 
Crisman
        Authors:  John Palmieri   |     Merged in:                              
    
   Dependencies:                  |      Stopgaps:                              
    
----------------------------------+-----------------------------------------

Comment (by slabbe):

 Replying to [comment:24 slabbe]:
 > 2. I really like the `table` function. I am defining such a function in
 a patch I posted just yesterday at #13069.

 To make the reference easier, here is the function I coded at #13069 (the
 patch is 90 Kb).

 {{{
 #!python
 def table_from_columns(col1, col2, space=3):
     r"""
     Return a string of a table of two columns.

     This is used by the ``_repr_`` method of DoubleSquare class.

     INPUT:

     - ``col1`` - list
     - ``col2`` - list
     - ``space`` - integer (default ``3``), number of space characters
       between

     EXAMPLES::

         sage: from sage.combinat.double_square_tile import
 table_from_columns
         sage: col1 = ['ab','asdfasdf', 'adf']
         sage: col2 = ['11', '1313', '131313', '1313']
         sage: print table_from_columns(col1, col2)
         ab         11
         asdfasdf   1313
         adf        131313
                    1313
     """
     from itertools import izip_longest
     width_col1 = max(map(len, col1))
     it = izip_longest(col1,col2, fillvalue='')
     L = [a.ljust(width_col1 + space) + b for (a,b) in it]
     return '\n'.join(L)
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13131#comment:27>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" 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 http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to