Abstract class in MicroPython

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
barbsbou
Posts: 10
Joined: Wed May 13, 2020 1:50 pm

Abstract class in MicroPython

Post by barbsbou » Fri Oct 07, 2022 12:46 pm

Dear community;

I would like to create a abstract class inherit from abc (Abstract Base Class) but I found nothing about lib ABC into micropython, maybe it is simply impossible or I did not search well....

Thank you for your replies and help!!

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Abstract class in MicroPython

Post by jimmo » Sun Oct 09, 2022 11:16 pm

This forum will be made read-only soon. Please post at GitHub Discussions.

MicroPython doesn't support abstract classes but if you're porting exisiting code that uses ABC, then you can just write an empty ABC class and abstractmethod decorator.

See
https://github.com/micropython/micropyt ... tdlib/abc/

barbsbou
Posts: 10
Joined: Wed May 13, 2020 1:50 pm

Re: Abstract class in MicroPython

Post by barbsbou » Mon Oct 10, 2022 1:53 pm

Thank for your reply!!

Jackli
Posts: 80
Joined: Thu Apr 29, 2021 9:11 am

Re: Abstract class in MicroPython

Post by Jackli » Thu May 25, 2023 8:17 am

Class name:
Phylum


class MyClass:
i=123

def f(self):
print("correct")

Post Reply