← index #350Issue #6366
Off-topic · high · value 1.824
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

no __dict__ attribute in a module object

closedby kdschlosseropened 2020-08-24updated 2024-09-23

chipset: ESP32
MicroPython version: 1.12

Traceback:

Traceback (most recent call last):
 File "boot.py", line 1, in <module>
 File "LEDS/__init__.py", line 134, in <module>
 File "LEDS/__init__.py", line 115, in __init__
AttributeError: 'module' object has no attribute '__dict__'

Code to reproduce error:

import sys

TEST_VARIABLE = 'This is a test'

print(sys.modules[__name__].__dict__)

Run the code above in both CPython and MicroPython, you will not get an error when it runs in CPython

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