"casting" Python objects

Donn Cave donn at drizzle.com
Fri May 24 00:25:54 EDT 2002


Quoth David Bolen <db3l at fitlinxx.com>:
| "Donn Cave" <donn at drizzle.com> writes:
|
|> Or, perhaps the right approach doesn't involve inheritance at all!
|
| Well, I was assuming that the Handler method was just one piece of the
| reason why FooMsg was subclassed from jabber.Message (since the
| original post was just an excerpt), but you're certainly right that
| there are other approaches as well not involving subclassing (such as
| the composition someone else posted).

Yeah, it's hard to say from here.  But I'm thinking that in
principle, you'd subclass a jabber.xxx class only if the
resulting instance was going _into_ the jabber module, where
its inheritance would allow it to function as a Message or
whatever in that context.

Otherwise it really sounds like a bad idea, and I wonder if
people overuse inheritance because it sounds like the OOP
thing to do.  I think the fact that it posed a problem here
is related to the reason why it might not be a good idea.

	Donn Cave, donn at drizzle.com



More information about the Python-list mailing list