dotmap icon indicating copy to clipboard operation
dotmap copied to clipboard

_repr_mimebundle_ added to the keys if executed from IPython

Open Kreol64 opened this issue 5 years ago • 3 comments

Hi,

I have a weird behavior when I execute the below code in IPython console (I use IntelliJ interactive console):

from dotmap import DotMap
d = DotMap({'a': 3}) 
d

This returns:

DotMap(a=3, _repr_mimebundle_=DotMap())

And if I test the number of keys:

print(len(d))

I get 2

I cannot reproduce this behavior in regular console, only with IPython

Kreol64 avatar Jan 21 '21 21:01 Kreol64

I also got a similar behavior that includes not only _repr_minmebundle_ but also _ipython_display_ with iPython (version 8.1.0, Python 3.8.10)

terasakisatoshi avatar Mar 22 '22 05:03 terasakisatoshi

@Kreol64 I found a workaround. Setting _dynamic=False does the trick.

from dotmap import DotMap
d = DotMap({'a': 3}, _dynamic=False) 
image

terasakisatoshi avatar Mar 22 '22 06:03 terasakisatoshi