Type checking in python?

Paul Prescod paul at prescod.net
Wed Jul 19 12:08:24 EDT 2000


Eric Hopper wrote:
> 
>...
> 
> OK, genericity.  I call generic programming 'inheritance for the lazy'.

But it has nothing to do with inheritance!

> Of the modern languages, the one I can think of right offhand is Java.
> And that's something I actually like about it.

Java does not require inheritance to do genericity either. Java does
require you to pre-declare your interfaces, but you "implement" an
interface. You do not inherit from it. The point is that there are three
different concepts here, unconstrained genericity,
inheritance-constrained genericity and interface-contrained genericity.
And we haven't even got to the subtle parts yet!

>         So, what class do you need to define a read method for?  Where did that
> object get passed in?  What if the read method is only called in some odd
> circumstance that manages to excape anyone's notice for years?

If you want to check that the read method is defined, you can do that at
method boundaries. You don't need to enforce an inheritance hierarchy.
-- 
 Paul Prescod - Not encumbered by corporate consensus
Just how compassionate can a Republican get before he has to leave the 
GOP and join Vegans for Global Justice? ... One moment, George W. Bush
is holding a get-to-know-you meeting with a bunch of gay Republicans.
The next he is holding forth on education or the environment ... It is
enough to make a red-blooded conservative choke on his spotted-owl
drumstick.     - April 29th, Economist




More information about the Python-list mailing list