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

2006-04-29 Thread Steve Holden
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > bruno at modulix <[EMAIL PROTECTED]> wrote: > > >>Lawrence D'Oliveiro wrote: >> >>>In article <[EMAIL PROTECTED]>, >>> bruno at modulix <[EMAIL PROTECTED]> wrote: >>> >>> >>> Lawrence D'Oliveiro wrote: (snip) >I

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

2006-04-28 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > >>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 re

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

2006-04-27 Thread bruno at modulix
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: > > >>Sandra-24 a écrit : >> >>>Lawrence D'Oliveiro wrote: >>> >>> In article <[EMAIL PROTECTED]>, "Sandra-24" <[EMAIL PROTECTED]> wrote: >Now that is a clever

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

2006-04-27 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, bruno at modulix <[EMAIL PROTECTED]> wrote: >Lawrence D'Oliveiro wrote: >> In article <[EMAIL PROTECTED]>, >> bruno at modulix <[EMAIL PROTECTED]> wrote: >> >> >>>Lawrence D'Oliveiro wrote: >>>(snip) >>> I think you're taking Python's OO-ness too seriously.

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

2006-04-27 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote: >Sandra-24 a écrit : >> Lawrence D'Oliveiro wrote: >> >>>In article <[EMAIL PROTECTED]>, >>> "Sandra-24" <[EMAIL PROTECTED]> wrote: >>> >>> Now that is a clever little trick. I never would have guessed you can >>>

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

2006-04-25 Thread bruno at modulix
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > bruno at modulix <[EMAIL PROTECTED]> wrote: > > >>Lawrence D'Oliveiro wrote: >>(snip) >> >>>I think you're taking Python's OO-ness too seriously. One of the >>>strengths of Python is that it can _look_ like an OO language without >

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

2006-04-25 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, bruno at modulix <[EMAIL PROTECTED]> wrote: >Lawrence D'Oliveiro wrote: >(snip) >> I think you're taking Python's OO-ness too seriously. One of the >> strengths of Python is that it can _look_ like an OO language without >> actually being OO. > >According to whic

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

2006-04-24 Thread Bruno Desthuilliers
Sandra-24 a écrit : > Lawrence D'Oliveiro wrote: > >>In article <[EMAIL PROTECTED]>, >> "Sandra-24" <[EMAIL PROTECTED]> 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

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

2006-04-24 Thread Sandra-24
Lawrence D'Oliveiro wrote: > > All you want is a dictionary, then. That's basically what Python objects > are. Yes, that's it exactly. I made a lazy wrapper for it, and I was really happy with what I was able to accomplish, it turned out to be very easy. Thanks, -Sandra -- http://mail.python.o

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

2006-04-24 Thread bruno at modulix
Lawrence D'Oliveiro wrote: (snip) > I think you're taking Python's OO-ness too seriously. One of the > strengths of Python is that it can _look_ like an OO language without > actually being OO. According to which definition of OO ? -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[

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

2006-04-23 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, "Sandra-24" <[EMAIL PROTECTED]> wrote: >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 membe

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

2006-04-23 Thread Sandra-24
Lawrence D'Oliveiro wrote: > In article <[EMAIL PROTECTED]>, > "Sandra-24" <[EMAIL PROTECTED]> 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

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

2006-04-22 Thread Peter Otten
Sandra-24 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. > > In this case it doesn't work. > > TypeError: __class__ assignment: only for heap types > > I suspect that's because this ob

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

2006-04-22 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, "Sandra-24" <[EMAIL PROTECTED]> 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. -- http://mail.python.org/

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

2006-04-22 Thread Sandra-24
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. In this case it doesn't work. TypeError: __class__ assignment: only for heap types I suspect that's because this object begins its life in C code. The

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

2006-04-22 Thread Peter Otten
Sandra-24 wrote: > Can you create an instance of a subclass using an existing instance of > the base class? > > Such things would be impossible in some languages or very difficult in > others. I wonder if this can be done in python, without copying the > base class instance, which in my case is a

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

2006-04-21 Thread Cavingdeep
With new-style classes you can find out a class' subclasses and then you can instantiate the subclass you want. Suppose you have two classes A and B, B is a subclass of A, A is a new-style class. Now you have an A's instance called "a", to instance B you can do the following: b = a.__class__.__sub

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

2006-04-21 Thread Lawrence D'Oliveiro
In article <[EMAIL PROTECTED]>, "Sandra-24" <[EMAIL PROTECTED]> wrote: >Can you create an instance of a subclass using an existing instance of >the base class? I think you're taking Python's OO-ness too seriously. One of the strengths of Python is that it can _look_ like an OO language without

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

2006-04-21 Thread Sandra-24
Can you create an instance of a subclass using an existing instance of the base class? Such things would be impossible in some languages or very difficult in others. I wonder if this can be done in python, without copying the base class instance, which in my case is a very expensive object. Any i