aisk / pick

create curses based interactive selection list in the terminal
MIT License
722 stars 61 forks source link

pick(options, title) doesn't return a tuple anymore, but an array of tuples #67

Closed PhunkyBob closed 2 years ago

PhunkyBob commented 2 years ago

Description

The function pick(options, title) doesn't return a tuple, but an array of tuples.

Steps to reproduce

I run the code given in example:

from pick import pick

title = "Please choose your favorite programming language: "
options = ["Java", "JavaScript", "Python", "PHP", "C++", "Erlang", "Haskell"]
option, index = pick(options, title)
print(option)
print(index)

Expected

Variables options and index are filled.

Actual result

Exception has occurred: ValueError not enough values to unpack (expected 2, got 1)

In debug mode, the function returns:

[('Python', 2)]

Suggestion

Since there is a "multiselect" option, I understand why it returns an array, but it breaks legacy scripts. I'ld suggest to return an array of tuples ony when multiselect=True.

Additional informations

Python version: 3.10.5 Pick version: 1.3.0

wong2 commented 2 years ago

This is an unexpected change introduced in https://github.com/wong2/pick/pull/59 I've reverted to the old behavior in v1.4.0, please upgrade. Sorry for the inconvenience.

PhunkyBob commented 2 years ago

Works fine in 1.4.0. Thank you.