interfaces?

drewpc at colorado.edu drewpc at colorado.edu
Thu Feb 1 16:31:13 EST 2001


Let me preface this posting by saying that I'm not a fan of Java.  A lot
of people may argue with me, but that's not the point.  The point is
that I think that, one of the only useful features of Java is the idea
of an interface.

If you know what a Java interface is, skip this paragraph.  For those of
you that don't know, here's how I understand it.  Imagine you're writing
an API for a database.  You want every database module (MySQL,
PostgreSQL, Oracle, etc) to implement the connect(), query(), insert(),
update(), and drop() methods.  What if you could create a pseudo class
that all of your database modules would "implement".  Meaning that the
pseudo class would define the methods (and variables too, I think)
connect(), query(), insert(), update(), and drop() methods.  It wouldn't
implement them at all, but just define them.  Then, inside each module
you'd "implement" (which would be a little different then "inherit") the
interface that you defined above.  All that means is that the compiler
(or interpreter) checks to make sure the the class that implements the
interface does in fact use the functions that were defined in the
interface.

Now, my question.  Is this something that people would be interested in
seeing in Python?  If so, then I think I'll write up a PEP (Python
Enhancement Proposal, http://python.sourceforge.net/peps/) about this.
Comments?  Cheap shots?  One-liners?


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list