def __init__(self):
Gary Herron
gherron at digipen.edu
Tue Apr 26 10:25:28 EDT 2016
On 04/26/2016 06:49 AM, Random832 wrote:
> On Tue, Apr 26, 2016, at 03:34, Ben Finney wrote:
>> That's needlessly confusing: ‘__init__’ is not a constructor because it
>> does not construct the instance. The ‘__new__’ method is the constructor
>> for a class (and returns the new instance).
> the __new__ method is the *allocator*. "constructor" is used in many
> languages to name a method that initializes an object once it already
> "exists". Saying you can't call it that in Python is needlessly
> confusing.
Agreed. For a newbie asking about __init__, I'll stick with my original
answer (that it's the constructor), and suggest ignoring the overly
pedantic (and confusing) response to the contrary.
--
Dr. Gary Herron
Professor of Computer Science
DigiPen Institute of Technology
(425) 895-4418
More information about the Python-list
mailing list