[Types-sig] Interface PEP

Sverker Nilsson sverker.is@home.se
Wed, 14 Mar 2001 14:20:22 +0100


I was wondering why, or if, the new concept of "interface" should be
introduced. There is already the concept of "type" in Python. I
thought that concept could/would/should be extended to cover more
general interfaces.

One would say then, I suppose, instead of

interface x...

something like

typedef x...

and the rest of the def would be essentially the same, I think.
Instead of the __implements__ special attribute, one would use
an attribute name more alluding to the type concept, I might want
to call it __type__.

The type() builtin would return, as usual, InstanceType if the
__type__ special attribute was not defined. Otherwise it would return
what __type__ returned. - which would be a user defined type (aka
interface) or even a builtin type, if the class wants to claim it
emulates a built-in type.

(Claiming is one thing of course, really doing it is another - 
there can never be any guarantee, I suppose.)

So.. what would be the reason to have interface another concept than
type?

Or should they be the same concept?

How about the __type__ name for the special attribute, aka
__implements__?

Regards,

Sverker Nilsson