← index #350Issue #601
Off-topic · high · value 2.910
QUERY · ISSUE

AttributeError: 'defaultdict' object has no attribute 'items'

openby Xiretzaopened 2019-09-09updated 2024-08-25
>>> from collections import defaultdict
>>> dd = defaultdict(list)
>>> dd
<defaultdict object at 2006e7d0>
>>> dd.items()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'defaultdict' object has no attribute 'items'

defaultdict doesn't have an items() method, so iterating over it is a bit of a pain in the neck. Also no __repr__(), but that's not totally necessary I guess.

2 comments
Rohith295 · 2021-06-15

Can I work on this issue? @xrmx

jonnor · 2024-08-25

This seems to still be the case - no "items()" function in the defaultdict module.

Anyone is welcomed to open merge requests in the MicroPython project :)

CANDIDATE · ISSUE

type object has no attribute __doc__

closedby wrobellopened 2014-05-10updated 2022-06-24

In Python 3.4, the following script works

from collections import namedtuple

T = namedtuple('T', 'a b')
T.__doc__ = 'Test'

When running with MicroPython I am getting the error

Traceback (most recent call last):
  File "t-doc.py", line 4, in <module>
AttributeError: 'type' object has no attribute '__doc__'

Funny enough, we probably expect all documentation to be removed by MicroPython, so T.__doc__ = 'Test' should probably do nothing?

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied