Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-18 Thread olsongt
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 bett

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-18 Thread Georg Brandl
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 be

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-16 Thread John Machin
Simon Forman wrote: > The entire post was meant as a pedantic exercise illustrating what not > to do (and how easy it is to figure that out with an interactive > session,) and sketching how to raise and check for an error instead. > Lessons usually start with the teacher asserting authority and

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-16 Thread Simon Forman
John Machin wrote: > Simon Forman wrote: > > > > > |>> class f: > > ... def __init__(self): > > ... del self > > Of course nothing happens. Args are local variables. 'self' is is a > vanilla arg of a vanilla function. I know. > > ... > > |>> e = f() > > |>> e > > <__main__.f insta

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread Steven D'Aprano
On Tue, 15 Aug 2006 16:04:12 -0700, 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? I don't believe so. Ge

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread John Machin
Simon Forman wrote: > > |>> class f: > ... def __init__(self): > ... del self Of course nothing happens. Args are local variables. 'self' is is a vanilla arg of a vanilla function. > ... > |>> e = f() > |>> e > <__main__.f instance at 0xb7dd91ec> > > > |>> class f: > ... def

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread Steve Holden
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 be

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread Ben Finney
tobiah <[EMAIL PROTECTED]> writes: > 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 bette

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread John Machin
tobiah wrote: > I should have made it more clear that Foo is a class: > > > class Foo: > > def __init__(self, *args): > > for arg in args: > if is_fruit(arg): > del(self) > > > > tobiah wrote: > > Suppose I do: > > > > -*> > m

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread Simon Forman
tobiah wrote: > I should have made it more clear that Foo is a class: > > > class Foo: > > def __init__(self, *args): > > for arg in args: > if is_fruit(arg): > del(self) > > > > tobiah wrote: > > Suppose I do: > > > > > > myfo

Re: Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread tobiah
I should have made it more clear that Foo is a class: class Foo: def __init__(self, *args): for arg in args: if is_fruit(arg): del(self) tobiah wrote: > Suppose I do: > > > myfoo = Foo('grapes',

Clean way to not get object back from instantiation attempt gone bad

2006-08-15 Thread tobiah
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? Thank