Does Python support interfaces?
gparlor at my-deja.com
gparlor at my-deja.com
Mon Jul 24 23:51:42 EDT 2000
In article <8l1org$a94
$1 at nntp9.atl.mindspring.net>,
aahz at netcom.com (Aahz Maruch) wrote:
> In article
<MPG.13dd4ec32cbe48e98982a at news.onlynews.com>,
> Randall Parker <rgparker at west.net> wrote:
> >
> >I'm quite new to Python. For those who are
familiar with Java interfaces:
> >Does Python have a similar facility?
> >
> >Can one declare interfaces, then declare that
a class implements some
> >interface, instantiate an object of that class
type, and then cast it to
> >an interface that it is declared to support
and then pass it around as a
> >reference to that interface type and make
calls to methods of that
> >interface type?
>
> Let me expand on Justin's post:
>
> Interfaces are *everything* in Python; you use
inheritance only when you
> want to borrow behavior from an existing
class. If I create a base
> class called MyFileType and implemented all the
standard methods and
> attributes, Python would literally not notice
that I was using a brand
> new class as a file object. All the standard
Python operations would
> just work. No casting, no subclassing.
> --
> --- Aahz (Copyright 2000
by aahz at netcom.com)
>
> Androgynous poly kinky vanilla queer het
<*> http://www.rahul.net/aahz/
> Hugs and backrubs -- I break Rule 6
>
> Q: In a lesbian relationship, who decides who
gets to be the man?
> A: It's two women. There is no man. That's
the point.
> Q: then who gets blamed when everything goes to
hell?
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list