Re: Cancel instance create

2008-09-09 Thread Fuzzyman
On Sep 6, 1:23 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > Mohamed Yousef schrieb: > > > ðWhat about no Constructor , and a custom instancing function that can > > return either None or the instance wanted > > That doesn't solve the underlying problem - the instance is created. > Just becau

Re: Cancel instance create

2008-09-06 Thread Terry Reedy
Fredrik Lundh wrote: Aigars Aigars wrote: I want MyClass to perform some tests and if them fail, I do not want instance to be created. If you do not want the instance created at all, you would have to write a custom .__new__ method, but that is tricky, something I would have to look up ho

Re: Cancel instance create

2008-09-06 Thread Aigars Aigars
I do not want code outside my class to perform tests and decide to create instance or not. Fredrik Lundh's advice to rise exception works perfectly. Thanks to all, Aigars Quoting Mohamed Yousef : ًWhat about no Constructor , and a custom instancing function that can return either None or the ins

Re: Cancel instance create

2008-09-06 Thread Diez B. Roggisch
Mohamed Yousef schrieb: ًWhat about no Constructor , and a custom instancing function that can return either None or the instance wanted That doesn't solve the underlying problem - the instance is created. Just because it wasn't *returned*, doesn't mean it isn't there. Diez -- http://mail.py

Re: Cancel instance create

2008-09-06 Thread Mohamed Yousef
ًWhat about no Constructor , and a custom instancing function that can return either None or the instance wanted -- http://mail.python.org/mailman/listinfo/python-list

Re: Cancel instance create

2008-09-06 Thread Fredrik Lundh
Aigars Aigars wrote: I want MyClass to perform some tests and if them fail, I do not want instance to be created. But in code I wrote instance is created and also has parameters, that it should not have in case of tests failure. Is there a way to perform tests in MyClass.__init__ and set in