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

conflict on accessing dict methods/attributes #5

Closed
yedpodtrzitko opened this issue Dec 13, 2014 · 8 comments
Closed

conflict on accessing dict methods/attributes #5

yedpodtrzitko opened this issue Dec 13, 2014 · 8 comments

Comments

@yedpodtrzitko
Copy link

from addict import Dict
a = Dict()
a.items = 'foo'
for k,v in a.items():
    print k,v

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'str' object is not callable
@jxnl
Copy link

jxnl commented Dec 13, 2014

the __getitem__ needs to check if item is an attribute and not overwrite it.
I can look into this sometime tomorrow tonight if no one else does.

@mewwts
Copy link
Owner

mewwts commented Dec 13, 2014

Yes, @jxnl, that's a good idea!

@jxnl
Copy link

jxnl commented Dec 13, 2014

#14 seems to fix the issue. let me know about any style issues

@mewwts
Copy link
Owner

mewwts commented Dec 13, 2014

This is fixed by ec26acb. Thanks @jxnl and @yedpodtrzitko

@mewwts mewwts closed this as completed Dec 13, 2014
@yedpodtrzitko
Copy link
Author

Wait what? You consider this as resolved by raising an exception? That makes it totally unusable

Imagine the situation: I got a dictionary from a frontend and now everything explodes, because it contains items? What I am supposed to tell to the frontend guys? "You cant use items, keys, and a bunch of other stuff there, because one of our libraries doesn't support it, you dickheads!"

@mewwts
Copy link
Owner

mewwts commented Dec 18, 2014

Hey, @yedpodtrzitko. You can still insert and read keys with protected names, but you would have to do that by using the get/set item syntax.

>>> a = Dict()
>>> a['items'] = [1, 2, 3]
>>> a
{'items': [1, 2, 3]}
>>> a['items']
[1, 2, 3]

So relax. Nothing explodes.

@yedpodtrzitko
Copy link
Author

oh... good

@mewwts
Copy link
Owner

mewwts commented Dec 18, 2014

Hope this works for you, @yedpodtrzitko 👍

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

No branches or pull requests

3 participants