Could Python supplant Java?

laotseu bdesth at
Thu Aug 22 03:39:21 CEST 2002

Lulu of the Lotus-Eaters wrote:
> |The way I look at it is this: when using a dynamically typed
> |language, how often do I mix the type of data I store in a
> |given variable?
> Far more often than you probably think, coming from a statically typed
> language.
> I agree that it is rarely necessary to change 'foo' from an integer to a
> string, or the like.  But I write a program like the below all the time:
>     def process_content(filelike):
>         text =
> stuff with text...
> 'filelike' might be a file handle.  It might be a urllib object.  It
> might be a gzip object.  It might be a string buffer.  Or it might be
> some custom object with a .read() method that I had not even thought of
> when I wrote the code.
> In some OOP languages you might handle this by requiring that 'filelike'
> inherit from File, or whatever.  

Or implements the 42 and a half methods of a IFile interface, even if 
your code just expects to use *one* particular method of this interface.

In Java, you sometime needs to write 41 (and a half) 'blank' methods to 
make sure an object of a given class can be passed to a method that uses 
only the 42nd.

> But that is far too rigid a class
> hierarchy requirement, IMO.

And it's far to rigid an interface hierarchy, and way far to much 
useless code to write.


More information about the Python-list mailing list