__init__() not called automatically
Steven Bethard
steven.bethard at gmail.com
Thu May 26 10:22:49 EDT 2005
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
More information about the Python-list
mailing list