-
-
Notifications
You must be signed in to change notification settings - Fork 45
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
Dictionary extraction such as c = {**a, **b} not functioning properly. #26
Comments
@heetbeet I'm not able to reproduce item 3, but I can reproduce 1 and 2. The issue seems to be that, because
are being ignored in these particular types of I can fix your cases by removing that inheritance and only having it inherit from If you have immediate suggestions, I'm open to them. Otherwise, I'll have to debug this at a later time. |
@drgrib I see. I switched over to the following implementation for my dot dictionary needs (I know it clashes for keys that are the same as the dictionary names - such as "pop", "update", "keys", "values", etc.):
So I am not in an immediate need for fixes. I'll switch back to DotMap in the future when doing a bit of code refactoring and the pip default is working nicely again. Thanks for the trouble. |
Shortest test on python2.7.13 for this issue: >>> dict(**dotmap.DotMap(a=1))
{} When using ** a lot this means DotMap fails as a dropin replacement for dictionaries. And it would be so nice to have just that. |
I've given this multiple shots and it's honestly too complicated to be worth the trouble when there is a simple workaround available already: >>> dict(**dotmap.DotMap(a=1).toDict())
{'a': 1} More on why completely acing the subclass in this manner is so difficult here. |
Fixed in #53 |
The following was tested on Linux Mint 17, Python version
Python 3.6.2 :: Anaconda custom (64-bit)
and dotmap versionsys.version_info(major=3, minor=6, micro=2, releaselevel='final', serial=0)
(lambda **x:x)(**DotMap(a=1))
returns an unexpected empty dictionary{}
,{**DotMap(a=1),**DotMap(b=2)}
returns an unexpected empty dictionary{}
, andm = DotMap(); m.a = 2; m.b = 3; print('{a} {b}'.format(**m));
fails withKeyError: 'a'
.Other functionality is working properly such as:
DotMap(a=1)['a']
returns an expected1
, andDotMap(a=1).a
returns an expected1
.The text was updated successfully, but these errors were encountered: