__init__ is the initialiser
Mark Lawrence
breamoreboy at yahoo.co.uk
Fri Jan 31 19:51:28 EST 2014
On 01/02/2014 00:13, Ethan Furman wrote:
> On 01/31/2014 03:43 PM, Ned Batchelder wrote:
>> On 1/31/14 6:05 PM, Ben Finney wrote:
>>> Ned Batchelder writes:
>>
>> I'm not hoping to change any official terminology. I just think that
>> calling __init__ anything other than a constructor
>> is confusing pedantry. It is a constructor, and Python constructors
>> work differently than those in C++ and Java.
>
> And I would say the opposite. __init__ is not creating anything, which
> is what I think of when speaking of a constructor. I'd be willing to
> yield the point that Python has a pair of methods that make up the
> constructor (an allocator and an initializer), but I found calling
> __init__ the constructor very confusing.
>
> --
> ~Ethan~
Here's what help says.
Python 3.4.0b2 (v3.4.0b2:ba32913eb13e, Jan 5 2014, 16:23:43) [MSC
v.1600 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help(object.__new__)
Help on built-in function __new__:
__new__(...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
>>> help(object.__init__)
Help on wrapper_descriptor:
__init__(...)
x.__init__(...) initializes x; see help(type(x)) for signature
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
More information about the Python-list
mailing list