-
Notifications
You must be signed in to change notification settings - Fork 446
Are stripe objects dicts? #494
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
Comments
stripe-python uses a custom dict object which supports lua/js-like behaviour of getting/setting keys through python attributes. In dj-stripe we try to treat them purely as dict. It's more consistent. |
Thanks! |
@oTree-org @jleclanche is correct, stripe-python's objects are indeed dicts with some additional magic to support dot notation. The reason the documentation uses the |
When reading the docs about subscriptions, customers, etc., I sometimes see attribute notation, like
And sometimes see dict notation, like
subscription['items']['data'][0].id
, and sometimes see a mix (e.g. in the previous example why not use ['id'] at the end?)What is the difference between the two? I was wondering if I could use dict notation all the way, like
subscription['items']['data'][0]['id']
. That means in my tests usingunittest.mock
I could patch the return values ofcreate
,retrieve
, etc. using simple dict literals.(By the way the docs have examples on how to use stripe-python, but I can't find any general explanation of how stripe-python is works, e.g. what data types it uses and how those map to JSON responses.)
Thanks!
The text was updated successfully, but these errors were encountered: