Paul McGuire wrote:
> 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.

Hooray ! You've just (re)discovered the state pattern... for which the
most stupid simple implementation in Python 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 anyway !-)

> Is this intended capability for Python
> objects, 

AFAIK, yes.

> or am I taking advantage of a fortuitous accident, which may get
> undone at a future time?

It's certainly not  a fortuitous accident.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in '[EMAIL PROTECTED]'.split('@')])"
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to