TypeError: can't create 'module' instances #9757
-
I did write some micropython classes to set the RTC with a NTP server and a class to handle the timezone time including handling of daylight saving time. Then I thought why not base the last one on the buildin time module class so localtime finally get a correct value. But that doesn't work: import utime Traceback (most recent call last): Is this a micropython restriction? Micropython classes cannot extend a class in a C language module? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
That is possible, but you're trying to inherit a module, not a class. There's no such thing as a 'module class' (as far as I'm aware). I'm not sure even CPython can do that. You can create a new module which hass all members of another module (e.g. https://softwareengineering.stackexchange.com/questions/298019/how-to-achieve-inheritance-when-using-just-modules-and-vanilla-functions-in-pyth). Or you can inherit a class. Btw isn't |
Beta Was this translation helpful? Give feedback.
-
There is a datetime in RTC (ESP32) but no timezone in there. Just a simple class to obtain a datetime tuple. The stack overflow topic discusses function inside a module. But utime is a class not a function. doing: from utime import * gives the same error. So it is not an import problem... As if you cannot extend a class from the c-language module in micropython? |
Beta Was this translation helpful? Give feedback.
-
? As opposed to for example
|
Beta Was this translation helpful? Give feedback.
dir
just shows members, that alone doesn't prove it's a class. I don't know what platform you're on, but don't you get?
As opposed to for example