[Tutor] constructors
Erik Price
erikprice@mac.com
Wed, 10 Apr 2002 07:35:13 -0400
On Wednesday, April 10, 2002, at 06:45 AM, Alexandre Ratti wrote:
> My understanding is that a constructor is useful to make sure that the
> object and its default values are initialised properly.
Since Python is loosely/weakly/dynamically typed, does initializing
really matter a great deal? Or is it just to allow us to use
polymorphism in a later method (by not requiring that later method to
specify a tuple over a list, for instance, because a tuple has already
been specified in the constructor, which makes the later method more
"general").
> The __init__ constructor is executed when a class instance is created,
> hence you are sure it runs once (at least in "classic" classes; the
> rules may have changed for the new-type classes in Python 2.2).
I am using 2.2 and probably won't need to use an older version. But can
you tell me a bit more about "new-type classes"? And how they're
different from "classic" classes?
Thank you,
Erik