In message , Nikola Skoric wrote:
> I have a file full of lines which I parse into Line objects. I also
> have two subclasses of Line, namely Individual and Family. Constructor
> of both subclasses needs all Line objects in the file to be
> constructed, so I cannot construct subclass objects in th
John Nagle writes:
> On 10/25/2010 7:38 AM, Tim Chase wrote:
>> While a dirty hack for which I'd tend to smack anybody who used it...you
>> *can* assign to instance.__class__
>
>That's an implementation detail of CPython. May not work in
> IronPython, Unladen Swallow, PyPy, or Shed Skin.
>
>
On 10/25/2010 12:56 PM, John Nagle wrote:
On 10/25/2010 7:38 AM, Tim Chase wrote:
While a dirty hack for which I'd tend to smack anybody who used it...you
*can* assign to instance.__class__
That's an implementation detail of CPython. May not work in
IronPython, Unladen Swallow, PyPy, or
Nikola Skoric writes:
> Hi everybody,
>
> I need to downcast an object, and I've read repeatedly that if you
> need to downcast, you did something wrong in the design phase. So,
> instead of asking how do you downcast in python, let me explain my
> situation.
>
> I have a 2-pass parser. 1st pass
> Hi everybody,
>
> I need to downcast an object, and I've read repeatedly that if you
> need to downcast, you did something wrong in the design phase. So,
> instead of asking how do you downcast in python, let me explain my
> situation.
>
> I have a 2-pass parser. 1st pass ends up with a bunch o
On 10/25/2010 7:38 AM, Tim Chase wrote:
While a dirty hack for which I'd tend to smack anybody who used it...you
*can* assign to instance.__class__
That's an implementation detail of CPython. May not work in
IronPython, Unladen Swallow, PyPy, or Shed Skin.
(An implementation with a JIT h
Dana Mon, 25 Oct 2010 09:38:42 -0500,
Tim Chase kaze:
> While a dirty hack for which I'd tend to smack anybody who used
> it...you *can* assign to instance.__class__
Wow! Python never stops to amaze me.
> If it breaks you get to keep all the parts :)
Yes, I can see great potential for shit hi
While a dirty hack for which I'd tend to smack anybody who used
it...you *can* assign to instance.__class__
>>> class A:
... def __init__(self, name):
... self.name = name
... def __str__(self): return self.name
...
>>> class B(A):
... def foo(self): print "I'm B: %r" % s