> >  I would like to know the interface concept in Python.How the
> > Interface is defined and implemented in Python?.

One way I have implemented interfaces, is as follows:

class MyInterface(object):
    def someMethod(self, argument):
        raise NotImplementedError()

If anybody ever uses that class directly, or subclasses it without
implementing a real version of that method, a runtime error can be
expected. This bridges both interfaces and abstract classes.

As others have pointed out, this isn't quite like a Java interface,
but I have found it useful to state my intentions up front, and that
is how I do it. The only way to truly enforce this is by following up
with lots of good test cases, run often.

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

Reply via email to