object.enable() anti-pattern

Roy Smith roy at panix.com
Sat May 11 09:31:12 EDT 2013


In article <518df898$0$29997$c3e8da3$5496439d at news.astraweb.com>,
 Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:

> I never intended to give the impression that *any* use of a separate 
> "enable" method call was bad. I certainly didn't intend to be bogged 
> down into a long discussion about the minutia of file descriptors in 
> C, but it was educational :-)

Well, you did say you were here for abuse.  I think you got your money's 
worth.  Can I interest you in a course of getting hit on the head 
lessons?

And just to be clear to the studio audience and all of you who are 
watching at home...

For all the effort I put into nit-picking, I do agree with Steven's 
basic premise.  Two-phase construction is usually not the right way to 
be designing classes.  Especially in languages like Python where 
constructors raising exceptions is both inexpensive and universally 
accepted as normal behavior.



More information about the Python-list mailing list