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

make process.extract accept {dict, list}-like choices #69

Merged
merged 1 commit into from Feb 19, 2015

Conversation

Projects
None yet
4 participants
@nathantypanski
Contributor

nathantypanski commented Nov 30, 2014

Previously, process.extract expected lists or dictionaries, and tested
this with isinstance() calls. In keeping with the spirit of Python (duck
typing and all that), this change enables one to use extract() on any
dict-like object for dict-like results, or any list-like object for
list-like results.

So now we can (and, indeed, I've added tests for these uses) call
extract() on things like:

  • a generator of strings ("any iterable")
  • a UserDict
  • custom user-made classes that "look like" dicts
    (or, really, anything with a .items() method that
    behaves like a dict)
  • plain old lists and dicts

The behavior is exactly the same for previous use cases of
lists-and-dicts.

This change goes along nicely with PR #68, since those docs suggest
dict-like behavior is valid, and this change makes that true.

make process.extract accept {dict, list}-like choices
Previously, process.extract expected lists or dictionaries, and tested
this with isinstance() calls. In keeping with the spirit of Python (duck
typing and all that), this change enables one to use extract() on any
dict-like object for dict-like results, or any list-like object for
list-like results.

So now we can (and, indeed, I've added tests for these uses) call
extract() on things like:

- a generator of strings ("any iterable")
- a UserDict
- custom user-made classes that "look like" dicts
  (or, really, anything with a .items() method that behaves like a dict)
- plain old lists and dicts

The behavior is exactly the same for previous use cases of
lists-and-dicts.

This change goes along nicely with PR #68, since those docs suggest
dict-like behavior is valid, and this change makes that true.
@erwaller

This comment has been minimized.

Member

erwaller commented Jan 5, 2015

@acslater00 how does this look?

@josegonzalez

This comment has been minimized.

Member

josegonzalez commented Feb 19, 2015

acslater00 added a commit that referenced this pull request Feb 19, 2015

Merge pull request #69 from nathantypanski/process-dict-like
make process.extract accept {dict, list}-like choices

@acslater00 acslater00 merged commit 89e27f3 into seatgeek:master Feb 19, 2015

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment