newbie-question: interfaces
merman
merman at freenet.de
Sat Apr 13 14:21:59 EDT 2002
"Paul Rubin" <phr-n2002a at nightsong.com> schrieb im Newsbeitrag
news:7xr8lja3l7.fsf at ruckus.brouhaha.com...
> Patrick W <xnexau at yahoo.com.au> writes:
> > 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.
>
> The purposes of interfaces in java is mostly to provide a form of multiple
> inheritance. Java doesn't support multiple base classes, so interfaces
> are a workaround for that. Python supports multiple base classes directly
> so it doesn't need a workaround.
Thanx for answers and sorry for my strange english ;-).
Note I'm a newbie:
1.) Yes, I want experimenting with the concept of course.
2.) Another reason is to accomplish a certain behaviour in the derived
class/ es.
I thought I can realize this goal either with abstract methods or
interfaces.
Is that an false idea?
o-o
Thomas
More information about the Python-list
mailing list