[PEAK] PyProtocols --

Phillip J. Eby pje at telecommunity.com
Sun Feb 15 21:35:28 EST 2004


At 11:06 PM 2/15/04 +0100, Gabriel Jägenstedt wrote:
>I've been looking into pyprotocols over the last week or so.
>I'm working on a textinterpreter for textgames, written in python and
>I've found I can't really implement all the object behaviour I want
>yet. What I'm looking for is something like multiple inheritence.
>I want to do this:
>
>class A:
>     """ This is a class that all objects are meant to inherit from
>It is most likely here I want to have the code to adapt other classes"""
>
>class B:
>     """A class that provides several methods and variables that extend
>the functionality of class A. I could most likely use inheritence to do
>this, somehow it doesn't seem right though. Using adaption it would
>be possible to have different adapters for differnt kinds of objects
>That I like"""
>
>class C:
>     """Here is an actual object class. It inherits from class A and also
>wishes to add the functionality of class B. As I said I wish it to
>happen in class A. All this class should need to do is:
>
>class c(A):
>
>addon = B (or IB if we are talking interfaces)
>
>"""

It would be most helpful if you could replace A, B, and C with the names 
and descriptions of the real-world things you're trying to do.  Then I 
could perhaps offer suggestions.  At the moment, I don't understand what it 
is you're trying to accomplish in your program.

Now, I'm going to make a guess that by text games, you mean interactive 
fiction, and I'm going to further guess that maybe you're trying to have a 
way to have objects respond to various actions.  And, that maybe objects 
have properties like weight or size that affects their ability to be 
carried, lockedness for doors, and so on.  And perhaps you'd like for 
command verbs (e.g. "pick up") to adapt the target object to an 
"ICarryable" protocol, and ask if it can be carried.  And, provide a 
default implementation for ICarryable that says the object can't be picked up.

Is this anything like what you're asking about?  Please describe the 
behavior you're trying to obtain, and focus less on how you're doing the 
classes right now.  (Because if what you have now doesn't work, that will 
just get in the way of us figuring out what *will* work.)

Thanks.




More information about the PEAK mailing list