Skip to content

Allow Table.add_column to use kwargs to create a new column #729

@eteq

Description

@eteq

(this was partially inspired by discussion in #726)

Right now, to create a new Column in a table, you have to do:

tab.add_column(Column(...))

that is, you have to explicitly create a Column object, even if that's the only thing you pass into add_column. I propose to enhance this to allow the following usage:

tab.add_column(name='a',data=somearray)

which would be the same as

tab.add_column(Column(name='a',data=somearray))

This would be fully backwards-compatible. The only catch is that the index and col keywords have to be available to add_column, so they can't be passed on to Column. This doesn't seem too much of a problem, though, because Column doesn't currently have either keyword (and I can't think of any reason why it would in the future).

I'm happy to implement this myself, but if @taldcroft or @astrofrog think it's a bad idea, I don't want to spend the time to do so.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions