astropy/astropy — pull request #2647 by mhvk (2014-06-20 19:56:14+00:00)
Title: Problem with TableColumns.__init__ for tuples, lists

The init function of TableColumns is wrong when passing a tuple or a list. I'm not sure why but it tries to look up for a name property in each element of it. Here is the code below.

```python
def __init__(self, cols={}):
if isinstance(cols, (list, tuple)):
cols = [(col.name, col) for col in cols]
super(TableColumns, self).__init__(cols)
```

Perhaps there is a *not* missing in the *if* statement, so that the parsing applies if it's some kind of structured object? Below is a small piece of code exampling the issues.

```python
x1 = np.arange(10.)
x2 = np.arange(5.)
x3 = np.arange(7.)
cols = [('x1',x1), ('x2',x2), ('x3',x3)]
TableColumns(cols) # Fails: ERROR AttributeError: 'list' object has no attribute 'name'
cols = (('x1',x1), ('x2',x2), ('x3',x3))
TableColumns(cols) # Fails: ERROR AttributeError: 'tuple' object has no attribute 'name'
cols = dict([('x1',x1), ('x2',x2), ('x3',x3)])
TableColumns(cols) # Works
```

The easiest fix is to remove the *if* block but I'm not sure what was the original intent here.