Skip to content

AttributeError in custom command #2490

Answered by midichef
brush701 asked this question in Q&A
Discussion options

You must be logged in to vote

Every argument to addColumn() except the named argument index is treated like a list of columns because of *cols:

def addColumn(self, *cols, index=None):

The solution is to use index= in front of your column index:

Sheet.addCommand('z.', 'addcol-freq', 'addColumn(FrequencyColumn(cursorCol), index=cursorColIndex+1)')

Also, a feature that may help you as you write code for visidata: to examine a traceback for errors like this, run the command error-recent (with the shortcut Ctrl+E). Or if you have more than one error, errors-all.

In this example, the traceback would offer this clue on where to look or add debug statements:

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@brush701
Comment options

Answer selected by brush701
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants