Could Python supplant Java?

Lulu of the Lotus-Eaters mertz at gnosis.cx
Wed Aug 21 17:50:21 CEST 2002


|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 = filelike.read()
        ...do 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.  But that is far too rigid a class
hierarchy requirement, IMO.

Yours, Lulu...

--
 mertz@   _/_/_/_/_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY:_/_/_/_/ v i
gnosis  _/_/                    Postmodern Enterprises         _/_/  s r
.cx    _/_/  MAKERS OF CHAOS....                              _/_/   i u
      _/_/_/_/_/ LOOK FOR IT IN A NEIGHBORHOOD NEAR YOU_/_/_/_/_/    g s





More information about the Python-list mailing list