| Deutsch English Français Italiano |
|
<methods-20230915133118@ram.dialup.fu-berlin.de> View for Bookmarking (what is this?) Look up another Usenet article |
Path: eternal-september.org!news.eternal-september.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: ram@zedat.fu-berlin.de (Stefan Ram)
Newsgroups: comp.lang.python
Subject: Re: Why doc call `__init__` as a method rather than function?
Date: 15 Sep 2023 12:42:13 GMT
Organization: Stefan Ram
Lines: 34
Expires: 1 Sep 2024 11:59:58 GMT
Message-ID: <methods-20230915133118@ram.dialup.fu-berlin.de>
References: <mailman.299.1694774984.23016.python-list@python.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: news.uni-berlin.de vBeQLHR1zT9ZMA9P8Ik/GwyWy6cJxsEjAKRG0KxfAZODal
Cancel-Lock: sha1:vBQhdLY7xAbAj32QL2iO0SPg0vM= sha256:QXiFBiKQevjAxaZGpbEVptaEvCEK2kp6m5OggPBSjnI=
X-Copyright: (C) Copyright 2023 Stefan Ram. All rights reserved.
Distribution through any means other than regular usenet
channels is forbidden. It is forbidden to publish this
article in the Web, to change URIs of this article into links,
and to transfer the body without this notice, but quotations
of parts in other Usenet posts are allowed.
X-No-Archive: Yes
Archive: no
X-No-Archive-Readme: "X-No-Archive" is set, because this prevents some
services to mirror the article in the web. But the article may
be kept on a Usenet archive server with only NNTP access.
X-No-Html: yes
Content-Language: en-US
Accept-Language: de-DE-1901, en-US, it, fr-FR
scruel tao <scruelt@hotmail.com> writes:
>The book PYTHON CRASH COURSE
I suggest to read "The Python Language Reference" (the "PRL")
by "Guido van Rossum and the Python development team" for
terminological questions.
>I wonder how can I call `__init__` as?
The PRL usually refers to the value of an object's __init__
attribute as a "method".
A method is a function that can be associated with a object
in a special way.
When a function is retrieved from the attribute of an instance,
an instance method object is created (PRL 3.11.1 3.2)
and becomes the value of the expression for the attribute.
This usually applies to "__init__". Methods are based on functions.
The method's __func__ attribute is the original function.
The instance is the method's __self__ attribute.
But when you look at values of __init__, you can find all
kinds of things, like "wrappers":
|>>> object.__init__
|<slot wrapper '__init__' of 'object' objects>
|>>> object().__init__
|<method-wrapper '__init__' of object object at 0x0...>
.