abstract base clases Flashcards

1
Q

what issubclass invoke?

A

__subclasscheck__(cls, sub) method of metaclass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

what isinstance invoke?

A

def __instancecheck__(cls, instance) method of metaclass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

class method for checking subclass

A

__subclasshook__(sub)

return True False or NontImplemented

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

register class as subclass

A

from abc import ABCMeta

class Text(metaclass=ABCMeta):
    pass

Text.register(str)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

abstract base class example

A

from abc import ABC

class MyClass(ABC)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

decorator for abstractmethods in ABC classes

A

from abc import abstractmethod

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

abstract descriptors must have

A

__isabstractmethod__ property

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

abstractmethod decorator must be …

A

innermost

How well did you know this?
1
Not at all
2
3
4
5
Perfectly