Clean way to not get object back from instantiation attempt gone bad
Steve Holden
steve at holdenweb.com
Tue Aug 15 20:56:04 EDT 2006
tobiah wrote:
> Suppose I do:
>
>
> myfoo = Foo('grapes', 'oranges')
>
> And in the __init__() of Foo, there is
> a real problem with the consumption of fruit.
> Is there a clean way to ensure that myfoo
> will be None after the call? Would the
> __init__() just do del(self), or is there
> a better way to think about this?
>
There's no way that the __init__() method can change the object of which
it's a method, since self is a variable local to the method (so changing
it won't change the object) and the method is required to return None.
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
More information about the Python-list
mailing list