Languages/Python2014. 12. 5. 14:09

import six

import abc


class MyAbstractClass(object):


    def abstract_method(self):

        while False:

            yield None

    def public_method(self):


class MyConcreteClass(MyAbstractClass):

    def abstract_method(self):


        if this method is omitted, following error is raised

        when public_method is called against an object.


            TypeError: Can't instantiate abstract class MyConcreteClass

            with abstract methods abstract_method


        print "abstract method is implemented."

    def __init__(self):



# below shows list of all the abstract methods.


print MyAbstractClass.__abstractmethods__

print MyAbstractClass.__mro__ # show method resolution order

print MyConcreteClass.__abstractmethods__

print MyConcreteClass.__mro__ # show method resolution order


# create an object of MyConcreteClass

# and call its 'public_method'.


entity = MyConcreteClass()


Posted by 이병준

소중한 의견, 감사합니다. ^^