Message397174
Ethan, here is the code I tried with 3.9, and the failure:
import abc
class Base(abc.ABC):
def __init_subclass__(cls, **kwargs):
instance = cls()
print(f"Created instance of {cls} easily: {instance}")
@abc.abstractmethod
def do_something(self):
pass
class Derived(Base):
pass
Derived()
Output:
python3 ~/temp/a.py ----VICMD----
Traceback (most recent call last):
File "/Users/ak/temp/a.py", line 53, in <module>
Derived()
TypeError: Can't instantiate abstract class Derived with abstract method do_something |
|
Date |
User |
Action |
Args |
2021-07-09 00:30:11 | andrei.avk | set | recipients:
+ andrei.avk, rhettinger, stutzbach, ethan.furman, BTaskaya, jbasko, tda |
2021-07-09 00:30:11 | andrei.avk | set | messageid: <1625790611.49.0.391270950285.issue35815@roundup.psfhosted.org> |
2021-07-09 00:30:11 | andrei.avk | link | issue35815 messages |
2021-07-09 00:30:11 | andrei.avk | create | |
|