jeremito schrieb:
> I am writing a class that is intended to be subclassed.  What is the
> proper way to indicate that a sub class must override a method?
> 
> Thanks,
> Jeremy
> 

What do you mean by 'indicate'? Writing it to the docstring of the
class/method? Writing a comment?

class Foo:
        """
        When inheriting from Foo, method foo must be    
        overridden. Otherwise SPAM.
        """
        def foo(self):
                print 'bar'

class Bar(Foo):
        def __init__(self):
                Foo.__init__(self)
        
        # Has to be defined to override the base class's method
        # when inheriting from class Foo. Otherwise: SPAM
        def foo(self):
                print 'foo'

I don't know any other way.

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to