preventing creation of instance
peter at engcorp.com
Wed Jun 18 16:47:44 CEST 2003
Mirko Koenig wrote:
> On Wed, 18 Jun 2003 14:42:36 +0200, Peter Hansen wrote:
> > Mirko Koenig wrote:
> >> Is using __new__ a common way in programming python like the contructor
> >> in c++ or is it seldom used ?
> > Perhaps the best answer is that it's *extremely* "new", no pun intended.
> > It was only just added to the language, and relatively few people have
> > probably tried using it, let alone figured out how to judge the best
> > time to use it, and when not to.
> > And many of us are still programming with older versions that didn't
> > have that feature.
> So perhaps throwing an exception in __init__ is the better way for me?
In my opinion, and certainly after seeing Aahz' comment, yes.
More information about the Python-list