Re: __init__() not called automatically
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.python archive

Re: __init__() not called automatically

From: Steven Bethard <steven.bethard@gmail.com>
Date: Thu May 26 2005 - 16:22:49 CEST

Sriek wrote:
> maybe like this:
> we can have the default behaviour as calling the default constructor
> ( with default arguements where required ). Along with this, keep the
> option open to call constructors explicitly.

Ok, so here's another example:

def init(self):
     print "An __init__ method, but in what class?!!"
     print "Oh, this class: %s" % type(self).__name__

class C(object):
     pass

C.__init__ = init

So how would the compiler know that init() is a constructor for the C
object? (You can figure that out at runtime, but I don't see how you can
generally figure that out at compile time.)

STeVe
Received on Thu Sep 29 16:14:21 2005