How do Java interfaces translate to Python?

Miki Tebeka tebeka at cs.bgu.ac.il
Mon Oct 1 03:32:58 EDT 2001


Hello Gordon,

If you look at interface as forcing some class to impelement a set of
methods then you can
do something like:

class SomeInterface:
    def f1(self):
        raise NotImplementedError
    def f2(self, arg1, arg2):
        raise NotImplementedError

And then every subclass of it must implement all the functions.

HTH.

--

Bye.
----------------------------------------------------------------------------
-
Smile, damn it, smile.

lambda msg: {
        'name' : 'Miki Tebeka',
        'email' : 'mikit at elrontelesoft.com',
        'url' : 'http://www.cs.bgu.ac.il/~tebeka',
        'quote' : 'The only difference between children and adults is the
price of the toys'
}[msg]

"Gordon Tyler" <gordon at doxxx.net> wrote in message
news:foJt7.34766$0%.5484714 at news1.busy1.on.home.com...
> Hi,
>
> I'm primarily a Java programmer but I dabble in Python on a regular basis.
> My current project is a low- and high-level interface to IRC which can be
> re-used to write IRC clients and bots.
>
> My question is this: Java being my primary language, I'm very used to
> using interfaces and I was wondering if there was an equivalent construct
> or idiom in Python? How does one do in Python what one would do with
> interfaces in Java?
>
> Thanks,
> Gordon





More information about the Python-list mailing list