| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
This change enables to retrieve the row as a dict and iterate the keys and/or items, like with a normal dict; in other words, making the Row object a dict-like object:
>>> row.dict()
{'name': 'Isabel', 'profession': 'bridge builder'}
>>> for k, v in row.items():
>>> for k in row.keys():
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.
|
Sorry, something went wrong.
|
I signed it! |
Sorry, something went wrong.
|
CLAs look good, thanks! |
Sorry, something went wrong.
|
I'd like to do a thorough review of the code (e.g. keys() and items() could be generators) but want to wait until @tswast comments on whether or not these features are desired. |
Sorry, something went wrong.
|
I see, good point about the generators, thanks. I'd fix that but will hold off until we know more about whether these are desirable at all. The thing is that it would be great to be able to either return the row as a dict or convert it to a dict really easily, which currently is a bit of a hacky process. Thanks! |
Sorry, something went wrong.
|
I fixed it after all; the tests seem to have run successfully :-) |
Sorry, something went wrong.
|
I like keys() and items() to make Row act even more like a dictionary. That part LGTM. What is your desired use for dict()? Are you using it to serialize the rows? |
Sorry, something went wrong.
|
I'm using dict() to serialise rows into a standard dict, which I can then convert to json. As long as keys() and/or items() makes it in, I'm happy not to have dict(), simply because I can do it in my own code. Alternatively, I'm happy to write a get() method for Row instead, so it's possible to get a value in a dict-standard failsafe way. Thanks! |
Sorry, something went wrong.
Yeah, I'd prefer not to have dict() since it's not a standard method and it's easy enough for someone to make their own dictionary now that there is keys() and items().
Ooh, yes please to adding the get() method. That sounds great. |
Sorry, something went wrong.
|
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
Sorry, something went wrong.
|
I signed it! |
Sorry, something went wrong.
|
CLAs look good, thanks! |
Sorry, something went wrong.
|
So dict() is now removed and get() is in place, including code checks and the tests for the module check out (not yet completed for the whole hog but that should be fine). Please let me know if there are any issues with my code I should fix. Thanks! |
Sorry, something went wrong.
| '' | ||
| """ | ||
| index = self._xxx_field_to_index.get(key) | ||
| if index is None: |
There was a problem hiding this comment.
Thanks for your contribution!
Sorry, something went wrong.
|
Thanks :-) |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This change enables to retrieve the row as a dict and iterate the keys and/or items, like with a normal dict; in other words, making the Row object a dict-like object: