Python Productivity over C++

David Bolen db3l at fitlinxx.com
Mon Jun 12 18:52:25 EDT 2000


gmcm at hypernet.com (Gordon McMillan) writes:

> Simply that in Python, inheritance doesn't necessarily have anything to do 
> with runtime behavior. (You can, of course, introduce that dependency, but 
> you'd be well advised not to.)

(...)

> That is, it's the interface that matters (not the derivation), and you 
> don't even have to get formal about that.

For me, this hit home in a small but practical case of overriding
sys.stdout with an alternate "file" object.  The requirement is that
it satisfy the interface (in this case, just a "write" method) and not
a particular class hierarchy.

This makes it extremely simple, and generally informal, to build a
class that fits the requirement (and/or augment an existing class that
may be deep in your own hierarchy) and use that as a replacement
sys.stdout object.  As long as you meet the interface requirements
(dynamically at run time) you're set.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list