[Tutor] Why error if method __init__ does not return none

ahimsa ahimsa@onetel.net.uk
Sat Mar 22 14:14:02 2003


To explore this a bit and to demonstrate my loss of the plot ...

would that mean something like: class 'a' is instantiated and then assign=
ed to=20
variable 'b' without 'a' actually calculating/operating on anything, simi=
lar=20
to a duplication of a recipe rather than say, the production of a cake wi=
th=20
that recipe? If the metaphor isn't stretched too far ... and the return o=
f=20
'none' is sort of like a place-holder to not allow that namespace to be b=
ound=20
to any other object before an instance of itself is assigned to - here -=20
variable 'b'?=20

Andy


On Saturday 22 Mar 2003 5:04 pm, Bob Gailer wrote:
> class a:
>    def __init__ (self):
>      return None
> b =3D a()
>
> What is "returned" here is an instance of the class, not what is return=
ed
> by the __init__ method. I guess that "TypeError: __init__() should retu=
rn
> None" is a way of telling you not to return something else with the
> expectation that it will be available.

--=20
News from a different perspective:
http://www.scoop.co.nz
http://www.fromthewilderness.com
____________________________
Prevent digital monopoly:
http://www.againsttcpa.com