no return values for __init__ ??

Gordon McMillan gmcm at hypernet.com
Sun Jan 9 19:18:00 EST 2000


Helge Hess wrote:
> Aahz Maruch wrote:
> > >Hm, I wonder why it is simpler to have two separate kinds of
> > >methods instead of a consistent behaviour for all methods ?
> > 
> > Because we're looking at it from two different perspectives. 
> > You're looking at the process from the bottom and I'm looking
> > at it from the top.  Providing your capability would make it
> > too easy for an inexperienced programmer to screw things up
> > royally.
> 
> I can't see on what you base this statement on ?! This capability
> generalizes, not specializes, the environment - which leads me to
> the assumption that the *current* state will make programmers
> wonder.
> 
> Until now I haven't heard a reason against this 'feature' which I
> can follow. I guess that it is just a matter of taste.

Is inheritance a matter of taste?
 
You claim to have patched your interpreter. Try this:

class A:
  def __init__(self):
    pass

class B:
  def __init__(self):
    return A()

class C(B):
  def __init__(self):
    self = B.__init__(self)
  def method(self):
    print "C.method called"

c = C()
c.method()

Produces an AttributeError, doesn't it?

- Gordon




More information about the Python-list mailing list