Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle other iterable sequences as "param[]=..." parameter values #94

Closed
liblit opened this issue Oct 4, 2017 · 0 comments
Closed

Handle other iterable sequences as "param[]=..." parameter values #94

liblit opened this issue Oct 4, 2017 · 0 comments
Assignees

Comments

@liblit
Copy link
Contributor

liblit commented Oct 4, 2017

Issue #55 pointed out that canvasapi 0.6.0 made it awkward to pass a list as a parameter value. Pull request #63 fixed this, with friendly support for both list and tuple from canvasapi 0.7.0 forward. Yay! However, list and tuple are just two of the many Pythonic ways to collect multiple values. It would be nice if canvasapi provided the same parameter-marshaling support for any parameter value that is actually an iterable collection of multiple values: set, generators, iterable objects returned by zip and ichain, etc. Note, however, that strings are a special case: str is iterable, but should be treated as a single value, not as a sequence of isolated characters.

An example of something that works in canvasapi 0.7.0:

course.list_multiple_submissions(student_ids='all', assignment_ids=[1, 2, 3])

Some examples of things that do not work in canvasapi 0.7.0:

# multiple values as a set
assignment_ids = set(...)
course.list_multiple_submissions(student_ids='all', assignment_ids=assignment_ids)

# multiple values as an iterator over dictionary values
mapping = {'a': 1, 'b': 2, 'c': 3}
course.list_multiple_submissions(student_ids='all', assignment_ids=mapping.values())

# multiple values as a generator expression
course.list_multiple_submissions(student_ids='all', assignment_ids=(assn.id for assn in ...))

Spoiler alert: I am already developing code to implement this feature. Expect a pull request soonish.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants