newbie-question: interfaces

Patrick W xnexau at yahoo.com.au
Sat Apr 13 11:30:24 EDT 2002


"merman" <merman at freenet.de> writes:

> > "merman" <merman at freenet.de> schrieb im Newsbeitrag
> > news:3cb7f47e$0$360$9b622d9e at news.freenet.de...
> > > Hi,
> > >
> > > is there a way to simulate interfaces (like in java) in python?
> > > ... or abstract classes? (c++/ java)
> > >
> > > o-o


Do you have a technical reason to actually want interfaces, or are you
simply experimenting with the concept?

As far as I can see, which is admittedly not that far, interfaces
don't really serve a useful purpose in Python. If you want
polymorphism in statically typed OO languages like C++ and Java, you
need to design your functions and methods to accept only objects
descended from a known type. But in Python, the type need not
(actually cannot) be specified at design time, so what purpose would
an interface serve? Wouldn't it be better to just inherit
_implementation_ when necessary, rather than to inherit pure
interfaces?

I ask this not to be a prick, but to find out if I'm missing something
important.



More information about the Python-list mailing list