astropy/astropy — pull request #2878 by embray (2014-08-21 22:03:22+00:00)
Title: Table.pprint() header ignores stdout redirection

As found in #2869, if one tries to redirect the output from `Table.pprint()`, the data get redirected, but the header does not (see below). My guess is that this is because `color_print`, which is used for the header, does not write to stdout.

```
In [1]: from astropy.table import Table, Column

In [2]: from contextlib import redirect_stdout

In [3]: t = Table([Column([1., 2.], 'a', unit='m'), Column(['a', 'b'], 'b')])

In [4]: t.pprint()
a b
m
--- ---
1.0 a
2.0 b

In [5]: with redirect_stdout(open("a.out", "w")):
t.pprint()
...:
a b
m
--- ---

In [6]: !cat a.out
1.0 a
2.0 b
```