Show More
@@ -225,6 +225,7 b' class SList(list):' | |||||
225 | """ sort by specified fields (see fields()) |
|
225 | """ sort by specified fields (see fields()) | |
226 |
|
226 | |||
227 | Example:: |
|
227 | Example:: | |
|
228 | ||||
228 | a.sort(1, nums = True) |
|
229 | a.sort(1, nums = True) | |
229 |
|
230 | |||
230 | Sorts a by second field, in numerical order (so that 21 > 3) |
|
231 | Sorts a by second field, in numerical order (so that 21 > 3) | |
@@ -310,6 +311,7 b' def list_strings(arg):' | |||||
310 | as input. |
|
311 | as input. | |
311 |
|
312 | |||
312 | :Examples: |
|
313 | :Examples: | |
|
314 | :: | |||
313 |
|
315 | |||
314 | In [7]: list_strings('A single string') |
|
316 | In [7]: list_strings('A single string') | |
315 | Out[7]: ['A single string'] |
|
317 | Out[7]: ['A single string'] | |
@@ -329,6 +331,7 b" def marquee(txt='',width=78,mark='*'):" | |||||
329 | """Return the input string centered in a 'marquee'. |
|
331 | """Return the input string centered in a 'marquee'. | |
330 |
|
332 | |||
331 | :Examples: |
|
333 | :Examples: | |
|
334 | :: | |||
332 |
|
335 | |||
333 | In [16]: marquee('A test',40) |
|
336 | In [16]: marquee('A test',40) | |
334 | Out[16]: '**************** A test ****************' |
|
337 | Out[16]: '**************** A test ****************' | |
@@ -499,6 +502,7 b' class EvalFormatter(Formatter):' | |||||
499 |
|
502 | |||
500 | Examples |
|
503 | Examples | |
501 | -------- |
|
504 | -------- | |
|
505 | :: | |||
502 |
|
506 | |||
503 |
In |
|
507 | In [1]: f = EvalFormatter() | |
504 |
In |
|
508 | In [2]: f.format('{n//4}', n=8) | |
@@ -524,6 +528,7 b' class FullEvalFormatter(Formatter):' | |||||
524 |
|
528 | |||
525 | Examples |
|
529 | Examples | |
526 | -------- |
|
530 | -------- | |
|
531 | :: | |||
527 |
|
532 | |||
528 | In [1]: f = FullEvalFormatter() |
|
533 | In [1]: f = FullEvalFormatter() | |
529 | In [2]: f.format('{n//4}', n=8) |
|
534 | In [2]: f.format('{n//4}', n=8) | |
@@ -578,6 +583,8 b' class DollarFormatter(FullEvalFormatter):' | |||||
578 |
|
583 | |||
579 | Examples |
|
584 | Examples | |
580 | -------- |
|
585 | -------- | |
|
586 | :: | |||
|
587 | ||||
581 | In [1]: f = DollarFormatter() |
|
588 | In [1]: f = DollarFormatter() | |
582 | In [2]: f.format('{n//4}', n=8) |
|
589 | In [2]: f.format('{n//4}', n=8) | |
583 | Out[2]: u'2' |
|
590 | Out[2]: u'2' | |
@@ -649,7 +656,7 b' def compute_item_matrix(items, empty=None, *args, **kwargs) :' | |||||
649 | Parameters |
|
656 | Parameters | |
650 | ---------- |
|
657 | ---------- | |
651 |
|
658 | |||
652 |
items |
|
659 | items | |
653 | list of strings to columize |
|
660 | list of strings to columize | |
654 | empty : (default None) |
|
661 | empty : (default None) | |
655 | default value to fill list if needed |
|
662 | default value to fill list if needed | |
@@ -661,25 +668,28 b' def compute_item_matrix(items, empty=None, *args, **kwargs) :' | |||||
661 | Returns |
|
668 | Returns | |
662 | ------- |
|
669 | ------- | |
663 |
|
670 | |||
664 | Returns a tuple of (strings_matrix, dict_info) |
|
671 | strings_matrix | |
665 |
|
||||
666 | strings_matrix : |
|
|||
667 |
|
672 | |||
668 | nested list of string, the outer most list contains as many list as |
|
673 | nested list of string, the outer most list contains as many list as | |
669 | rows, the innermost lists have each as many element as colums. If the |
|
674 | rows, the innermost lists have each as many element as colums. If the | |
670 | total number of elements in `items` does not equal the product of |
|
675 | total number of elements in `items` does not equal the product of | |
671 | rows*columns, the last element of some lists are filled with `None`. |
|
676 | rows*columns, the last element of some lists are filled with `None`. | |
672 |
|
677 | |||
673 |
dict_info |
|
678 | dict_info | |
674 | some info to make columnize easier: |
|
679 | some info to make columnize easier: | |
675 |
|
680 | |||
676 |
columns_numbers |
|
681 | columns_numbers | |
677 |
|
|
682 | number of columns | |
678 | columns_width : list of with of each columns |
|
683 | rows_numbers | |
679 | optimal_separator_width : best separator width between columns |
|
684 | number of rows | |
|
685 | columns_width | |||
|
686 | list of with of each columns | |||
|
687 | optimal_separator_width | |||
|
688 | best separator width between columns | |||
680 |
|
689 | |||
681 | Examples |
|
690 | Examples | |
682 | -------- |
|
691 | -------- | |
|
692 | :: | |||
683 |
|
693 | |||
684 | In [1]: l = ['aaa','b','cc','d','eeeee','f','g','h','i','j','k','l'] |
|
694 | In [1]: l = ['aaa','b','cc','d','eeeee','f','g','h','i','j','k','l'] | |
685 | ...: compute_item_matrix(l,displaywidth=12) |
|
695 | ...: compute_item_matrix(l,displaywidth=12) | |
@@ -693,7 +703,6 b' def compute_item_matrix(items, empty=None, *args, **kwargs) :' | |||||
693 | 'columns_width': [5, 1, 1], |
|
703 | 'columns_width': [5, 1, 1], | |
694 | 'optimal_separator_width': 2, |
|
704 | 'optimal_separator_width': 2, | |
695 | 'rows_numbers': 5}) |
|
705 | 'rows_numbers': 5}) | |
696 |
|
||||
697 | """ |
|
706 | """ | |
698 | info = _find_optimal(list(map(len, items)), *args, **kwargs) |
|
707 | info = _find_optimal(list(map(len, items)), *args, **kwargs) | |
699 | nrow, ncol = info['rows_numbers'], info['columns_numbers'] |
|
708 | nrow, ncol = info['rows_numbers'], info['columns_numbers'] |
General Comments 0
You need to be logged in to leave comments.
Login now