mirror of
				https://github.com/KevinMidboe/tableprint.git
				synced 2025-10-29 18:00:16 +00:00 
			
		
		
		
	Better python2 compatibility (six.string_types)
This commit is contained in:
		| @@ -1 +1,2 @@ | |||||||
| numpy | numpy | ||||||
|  | six | ||||||
|   | |||||||
| @@ -3,18 +3,18 @@ Tableprint | |||||||
|  |  | ||||||
| A module to print and display ASCII formatted tables of data | A module to print and display ASCII formatted tables of data | ||||||
|  |  | ||||||
|  | Usage | ||||||
|  | ----- | ||||||
|  | >>> data = np.random.randn(10,3) | ||||||
|  | >>> headers = ['Column A', 'Column B', 'Column C'] | ||||||
|  | >>> tableprint.table(data, headers) | ||||||
| """ | """ | ||||||
|  |  | ||||||
| from __future__ import print_function | from __future__ import print_function | ||||||
| try: | from six import string_types | ||||||
| import numpy as np | import numpy as np | ||||||
| except ImportError: |  | ||||||
|     pass |  | ||||||
|  |  | ||||||
| # exports |  | ||||||
| __all__ = ['table', 'row', 'header', 'hr', 'humantime', 'frame'] | __all__ = ['table', 'row', 'header', 'hr', 'humantime', 'frame'] | ||||||
|  | __version__ = '0.2.0' | ||||||
| __version__ = '0.1.9' |  | ||||||
|  |  | ||||||
|  |  | ||||||
| def table(data, headers, format_spec='5g', column_width=10, outer_char='|', corner_char='+', line_char='-'): | def table(data, headers, format_spec='5g', column_width=10, outer_char='|', corner_char='+', line_char='-'): | ||||||
| @@ -138,7 +138,7 @@ def row(values, column_width=10, format_spec='5g', outer_char='|'): | |||||||
|         # unpack |         # unpack | ||||||
|         d, prec = val |         d, prec = val | ||||||
|  |  | ||||||
|         if isinstance(d, str): |         if isinstance(d, string_types): | ||||||
|             return ('{:>%i}' % column_width).format(d) |             return ('{:>%i}' % column_width).format(d) | ||||||
|  |  | ||||||
|         elif isinstance(d, (int, float, np.integer, np.float)): |         elif isinstance(d, (int, float, np.integer, np.float)): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user