[Python-Dev] PEP 246, Object Adaptation (was Re: Single- vs. Multi-pass iterability)

Clark C . Evans cce@clarkevans.com
Mon, 15 Jul 2002 12:01:33 -0400


On Mon, Jul 15, 2002 at 10:32:18AM -0400, Barry A. Warsaw wrote:
|     |     class C:
|     |         def open(self, name, flags=None):
|     |         def read(self):
|     |         def write(self, value):
|     |         def close(self):
| 
|     A> Can instances of C be used where a file object is expected?
| 
| Maybe <wink>.
| 
| That's why you tend to see things described like: "argument f must
| have a write() method that accepts a string."  WIBNI we could define a
| protocol/interface/thingie that encapsulated that requirement?

Even if write accepts a string it may not do what you expect.  *grin*

| I'd even be happy to start out with no officially blessed interfaces, to
| give time to see what cream rises to the top.  Zope's Interface and
| component model stuff is a good way to get some real experience with
| using these concepts in Python.

Well, with the Object Adaptation proposal you don't even need to bless
a particular compliance mechanism.   For ease of use, the built-in
may want to use a few mechanisms; but this is a distinct difference.
What ever is chosen, I hope the core syntax isn't mucked with!

Best,

Clark

-- 
Clark C. Evans                   Axista, Inc.
http://www.axista.com            800.926.5525
XCOLLA Collaborative Project Management Software