Re: Assigning to self.__class__

2006-01-26 Thread Terry Reedy
"Paul McGuire" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >I have some places in pyparsing where I've found that the most > straightforward way to adjust an instance's behavior is to change its > class. > I do this by assigning to se

Re: Assigning to self.__class__

2006-01-26 Thread Alex Martelli
Heiko Wundram <[EMAIL PROTECTED]> wrote: > bruno at modulix wrote: > > Paul McGuire wrote: > >> or am I taking advantage of a fortuitous accident, which may get > >> undone at a future time? > > > > It's certainly not a fortuitous accident. > > And even the (printed) cookbook has examples which

Re: Assigning to self.__class__

2006-01-26 Thread Heiko Wundram
bruno at modulix wrote: > Paul McGuire wrote: >> or am I taking advantage of a fortuitous accident, which may get >> undone at a future time? > > It's certainly not a fortuitous accident. And even the (printed) cookbook has examples which assign to self.__class__... I guess this means this featu

Re: Assigning to self.__class__

2006-01-26 Thread bruno at modulix
ython is to : >(snip) assigning to self.__class__, (snip) !-) > > Any comments on this practice? It can be very confusing for newbies and peoples having no experience with *dynamic* languages, and I guess control-freaks and static-typing-addicts would runaway screaming. But I like it

Assigning to self.__class__

2006-01-26 Thread Paul McGuire
I have some places in pyparsing where I've found that the most straightforward way to adjust an instance's behavior is to change its class. I do this by assigning to self.__class__, and things all work fine. (Converting to use of __new__ is not an option - in one case, the change is