QUERY · ISSUE
AttributeError: 'defaultdict' object has no attribute 'items'
>>> 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.
CANDIDATE · ISSUE
AttributeError: 'function' object has no attribute '__name__'
Some (maybe all) of the builtin functions do not have a __name__ attribute like regular functions:
>>> def f(x):
... return x
...
>>> f.__name__
'f'
>>> from math import sin
>>> sin.__name__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute '__name__'
Additionally, micropython does not currently allow assignment/reassignment of function attributes like CPython does:
micropython
>>> f.__name__ = 'g'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute '__name__'
>>> f.some_attr = 'some value'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'some_attr'
>>> sin.__name__ = 'g'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute '__name__'
>>> sin.some_attr = 'some value'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'function' object has no attribute 'some_attr'
CPython
>>> f.__name__ = 'g'
>>> f.some_attr = 'some value'
>>> sin.__name__ = 'g'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: attribute '__name__' of 'builtin_function_or_method' objects is not writable
>>> sin.some_attr = 'some value'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'builtin_function_or_method' object has no attribute 'some_attr'
Can I work on this issue? @xrmx
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 :)