Can you create an instance of a subclass with an existing instance of the base class?

bruno at modulix onurb at xiludom.gro
Thu Apr 27 05:03:45 EDT 2006


Lawrence D'Oliveiro wrote:
> In article <444d4b92$0$7905$636a55ce at news.free.fr>,
>  Bruno Desthuilliers <bdesth.quelquechose at free.quelquepart.fr> wrote:
> 
> 
>>Sandra-24 a écrit :
>>
>>>Lawrence D'Oliveiro wrote:
>>>
>>>
>>>>In article <1145736124.831082.34550 at v46g2000cwv.googlegroups.com>,
>>>>"Sandra-24" <sandravandale at yahoo.com> wrote:
>>>>
>>>>
>>>>
>>>>>Now that is a clever little trick. I never would have guessed you can
>>>>>assign to __class__, Python always surprises me in it's sheer
>>>>>flexibility.
>>>>
>>>>That's because you're still thinking in OO terms. 
>>>
>>>It's not quite as simple as all that. I agree that people, escpecially
>>>people with a Java (ew) background overuse OO, when there's often
>>>simpler ways of doing things.
>>
>>Nope. I mean : they don't overuse OO, they overuse *classes*. AFAIK, OO 
>>means *object* oriented - not class oriented.
> 
> 
> Oh great. Now we have someone redefining the concept of OO to evade the 
> point I was making.

"redefining" ? lol...

> 
>>There are OO languages that don't even have a notion of class.
> 
> 
> Sounds like stuff I was doing in C (a non-OO language) years ago. Unless 
> you want to count C as an OO language, I think you're going to have to 
> retract this claim.

I think I'm not going to retract anything. And I think you should learn
a bit more about prototype-based languages.

> 
>>>However in this case I'm simply getting an object (an mp_request object
>>>from mod_python) passed into my function, and before I pass it on to
>>>the functions that make up and individual web page it is modified by
>>>adding members and methods to add functionality.
>>
>>Which is a well-known design pattern called "decorator".
>  
> If you have to think of it as a design pattern, that means you haven't 
> figured out the code reuse angle yet.

Please stop saying non-sense and learn the difference between design and
implementation.

-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list