I am using rp2-pico-20210411-unstable-v1.14-152-g6f06dcaee.uf2 on my Raspberry pi Pico board. I tried the following class samples in 'Thonny 3.3.6' with the following error message:
>>> %Run -c $EDITOR_CONTENT
This is a static method
I can do something with self.
Traceback (most recent call last):
File "<stdin>", line 27, in <module>
TypeError: can't convert Data to int:
line 27 is: print(hex(d))
---------------------------------------------------------------------------------------------------------------------
def static_method(self):
print("This is a static method")
def object_method(self):
print("I can do something with self.")
p = Person()
Person.static_method(p)
p.object_method()
#____________________________________________________________
class Data:
id = 0
def __index__(self):
print('__index__ function called')
return self.id
d = Data()
d.id = 100
print(hex(d))
------------------------------------------------------------------------------------------
All works fine with Python versions 3.7 - 3.9 . What is the problem with MicroPython or my code?