Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

You have mail.


devel / comp.lang.python / Re: Why doc call `__init__` as a method rather than function?

SubjectAuthor
* Why doc call `__init__` as a method rather than function?scruel tao
`- Re: Why doc call `__init__` as a method rather than function?Stefan Ram

1
Why doc call `__init__` as a method rather than function?

<mailman.299.1694774984.23016.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23991&group=comp.lang.python#23991

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail
From: scru...@hotmail.com (scruel tao)
Newsgroups: comp.lang.python
Subject: Why doc call `__init__` as a method rather than function?
Date: Fri, 15 Sep 2023 10:49:10 +0000
Lines: 21
Message-ID: <mailman.299.1694774984.23016.python-list@python.org>
References: <OS3P286MB0740BDD307B9BEB732BD2256A5F6A@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
Mime-Version: 1.0
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de iIx0RJbWuK6reYm92xa4QQN78z4EwwdyqaQIix87QOKg==
Cancel-Lock: sha1:U5At3EbR2/e5R/ZMg0+uWvajbDw= sha256:Z3XNW2p4jd0Cg8etW+s46gjzqumLW0CyvXR7cSgKWMU=
Return-Path: <scruelt@hotmail.com>
X-Original-To: Python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=hotmail.com header.i=@hotmail.com header.b=IkIN8UHi;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.015
X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'def': 0.04;
'&gt;&gt;&gt;': 0.07; 'subject:Why': 0.07; 'subject:doc': 0.09;
'url-ip:13.107.213.67/32': 0.09; 'url-ip:13.107.213/24': 0.09;
'url-ip:13.107.246.67/32': 0.09; 'url-ip:13.107.246/24': 0.09;
'function...': 0.16; 'subject:call': 0.16; 'python': 0.16;
'to:addr:python-list': 0.20; 'maybe': 0.22; 'skip:_ 10': 0.22;
'thanks!': 0.24; 'to:name:python-list@python.org': 0.24; 'seems':
0.26; 'object': 0.26; 'function': 0.27; '>>>': 0.28; 'output':
0.28; 'think': 0.32; 'official': 0.32; 'book': 0.35; 'really':
0.37; 'class': 0.37; 'url-ip:13.107/16': 0.38; 'mentioned': 0.39;
'use': 0.39; 'explain': 0.40; 'both': 0.40; 'want': 0.40;
'charset:windows-1252': 0.60; 'method': 0.61; 'skip:0 20': 0.61;
'pass': 0.64; 'authors': 0.64; 'url-ip:104.18/16': 0.67;
'subject:method': 0.69; '&quot;a': 0.76; '....': 0.76;
'subject:than': 0.91
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=YEAcLzRWSmRPKbA2FYsko952CGLMMWCUlgxLI74GtuTGO+X18xmJFgr7Frmu0/uSUJc0GTK9VnkUkFLs/d3iLrmRAjHFnmjtBaTh83SB0DH+odC2+FZBAa0XD3Wlfps9SZ0xJp2eENim+To/2JQpBYfNx3w/cID6+KYds3rE3kNQxadjf8n7fjvLmX/+yYphJB2D7/CmYYmyECalerDFhfZ2n+34BoxwjpkWbLZ1MxvcclFQ1750X46kHtv166oaKSuLgqylhgogrO0yx7A/cjpG79YrkfrDeRq/HivRbgmZeGLJXCCq33C9Kj2EfZ+8Pgyrpa0H8Ba9LZp7vEqlbQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=SNTPlKBcJFKKHapZB0QvRohImCF5W5c1i3UQiXmXtEc=;
b=QP6YUhku0FJunnUc24D3dB86oN7jmTk2pEz2KMShy5kUiWTzy9lNOSn7nU/10avmtRw0H/rvjUSjCf9TIdymOPoXfaBcqre6Cc7pnClrjW/1pzQ/PIA++gIJB/ljFx+HeAOCaz7RDsD1mY6IUaYO1hQDRbwPhg4SktpwAE+AiXrXXJndhlOSoiyVklu3d1Sm27jYrGcG7aps/hfDGPaySZhMi5B7mKc/3A7N8w4zRGHU9tv0PTb0GpbDM0swy4rLG6sh+uPsqDcXP2NEtnFhhLF6u8esKCJ2Xhweucnf+tkzKa7OVm+CWoJvYOqPAp8rG9Xtapu6YM77TmzJ35qxXA==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
dkim=none; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com;
s=selector1;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=SNTPlKBcJFKKHapZB0QvRohImCF5W5c1i3UQiXmXtEc=;
b=IkIN8UHikYCeiHIE3oc4t0xsxe6stmy670ooO+4yUY00ODe2DdSfwabPbUFW+6MZtNg3PYkH+E+tXVQtvTruh7av3K3hOgDNK48DfY/T67UCTT3kymVZi7I+s6rD4nQ24Lj3bnKF9c9zAbb4ZJeVHhIQ/z//e2KWw6rzmqLSTD5gF8CdRYi+E+q0D9QGMbw3qeFMsXF5UKLT2pHyDnoFGyNhiaJBXVn5yPeQ0b/V1JxplT6LiIM6pnBaVtoeG+PkMayw//mgseffXWhYuRnZKFUXGD0rQ0dop/U1YiZ3EgSk/P66jjWQktXs/gCnjNduzdMpbqRjkHgpwQq0vyAbVw==
Thread-Topic: Why doc call `__init__` as a method rather than function?
Thread-Index: AQHZ58BrZpWMmMM+jEWDF+LlUUfVag==
Accept-Language: zh-CN, en-US
Content-Language: zh-CN
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-messagesentrepresentingtype: 1
x-tmn: [eIpF5g6dPF7daS/kbN1F7NqSYP6aspOT]
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: OS3P286MB0740:EE_|TYCP286MB3409:EE_
x-ms-office365-filtering-correlation-id: 8b8455f1-8775-4784-d553-08dbb5d964e5
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: PCa5GHdC7xK5TTjTB1YZb/YiLVHbm/hUKr5dGOchj0A1ErEzUQcvpsUZRpu8krNesku8vdCiAcvPfWRNnG1vbd6+/anFelhWAsYDp358apluogi5h/MZC7FAQrQ/JYdPKp153IqScWEA4+k0gA5cZoAWvRF6OZcgpbZgdTT+x5XmNbQGrBW9puZVEd1f5Tszkf6T9b9LECqFqCQkoXofTOPd7aGkdT62OdhIl98mWgWv28u+Xg3Nc80E9lMLNyxpR1jDO3i03jZdcA897FLJHwmPvOXftPx/QjsiYwgr8yS5J/5rT8VZL6MWqmZ8mwvvAhBPX4ZW5BSuBQl7Zd/JPi+550qbNYCycS7pNDN3yp1vWNlVP3QziZrgWqpOY4DactBbOT9NJTmGo3vCJgmQM4oW1JoFErvP3GFd39YWeD6Ni1pCzU0cLZr4YGuGV0uQL2SGTI1pYdlVan5kSYwhfUq72Of4xpfPuzuUVY94MzoPiHZdjnbPPfxdHBsuldSQ3HFnVDELoeTvunTybhyO0fRmOmhT1UTLnHs3rTzlZ3V2RbFUPA+O93IcbiKMolZW
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: /wbgC97oa+2nq3So9LjgR6+HkUCf6XZPJXak/OFs/keqcznju87B92Hy
DbHJzKX0xiidd5SfcoH0ORZ84yhsXkR6yF7AyaUg5BfzcugiEIl5bOBZ
ep3cbCe7peQkEiuFgk6kO2kbepcaK1eNNa7MhngF3dux/CzjhnUORMEy
AW6/dyanTvPL2ziGycVUBJ7fnhVTW1v5koE2zGxTHWJmN/u9KUXxO2E6
/Vry88EoVNIguRnrvOov+lhgLhqPjYmB2BZzioZvXa0epOlJYrr0+jU0
ZBoBdBHLz6uCCYs6tv60s1bLbVZDPUvQJaF7CEx9XSzb2wACHgyyWLXH
KVajfp9t4JwB5/RWpEdqkyM+mXG4hkXqZMib2SRefFMs5Pzejnh/5cOm
1iWHSzJqWtlTTfYENfsVWss4fFUz6NIyOL3n9Ku4C8IF+oSK+7QkezGB
xpImNcoZStq2yGMqddES7lDKGKHnK9GpekS1ZaYlAWJI71A8VIDZmkqm
f+GbncE4ZqV2HVF+SpJ1FKqorN3LyWUeqbzYl0Dp5qiXP14/Jn/t2zYG
Mhn0JPrwjBkRYRQ/OUu5PGTA6rDecekETU3QZErRFW/QvTSfpXp1qy4i
FIbFoXcVdf0v9sZmSRs/uXNBsuleHQ7bi9vWmad0Z26H0sCBEApS55X3
ckcTUh+euNpvnViJTpw3ni/KCi87BweI87yh3X4CP+dB5Aom21B6v7vD
/KjaF2l4o7G1S0ttZVkco7zao1oZ8oCZnuwBgueFlTszQgdeewJH2XAp
eHrTEdND2FNmRWtYGe2y2Uwd3VKurP7hjFKh2O3clJMllPeR87bCI2hD
ooulq0+bZd+ouk2980knrCZHqJqdjDtU4XPB1EeD5sb6zwUHZZbYfBtO
zmKl8BUcNwIJHBcihfQVf7sMXWeR8sbQu11f6KIlBxPnwRUQZ88J2hTI
dnTpIMoq3aRkgXo+keIg3xIn8PDZ0zWLNJOzPJs6flwIKYji7Aw4NmP3
W+KsP0f4MJRODWKe7iBqSzLyRg7l81v8sOFx0TPeU8f5u4wM+VCN4B8s
lFRtBXDB/If49PRYzPz1ilJ1Gm1VzOPMzLjTyrOtap8R/41azvWjNCl+
dB51tQZgGZ18lSaKJKIvVojnlX6zYECEjk/HPk0E5UwQZjB43Y8AAuk6
wpPkq3DOPqcm7gY2BH/1NOLm5L+MD6NGMl1zRKmr5H/3B7gkuPOaOJ+5
f0Jlp6tADaf2oOil/SnHoLrHV4g=
X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-05f45.templateTenant
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-Network-Message-Id: 8b8455f1-8775-4784-d553-08dbb5d964e5
X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Sep 2023 10:49:10.8214 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCP286MB3409
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <OS3P286MB0740BDD307B9BEB732BD2256A5F6A@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
 by: scruel tao - Fri, 15 Sep 2023 10:49 UTC

```python
>>> class A:
.... def __init__(self):
.... pass
....
>>> A.__init__
<function A.__init__ at 0x0000026CFC5CCEE0>
>>> a = A()
>>> a.__init__
<bound method A.__init__ of <__main__.A object at 0x0000026CFC1BB400>>
```

On many books and even the official documents, it seems that many authors prefer to call `__init__` as a "method" rather than a "function".
The book PYTHON CRASH COURSE mentioned that "A function that’s part of a class is a method.", however, ` A.__init__` tells that `__init__` is a function...

I wonder how can I call `__init__` as? Consider the output above.
Maybe both are OK? If you prefer or think that we must use one of the two, please explain the why, I really want to know, thanks!

Re: Why doc call `__init__` as a method rather than function?

<methods-20230915133118@ram.dialup.fu-berlin.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=23992&group=comp.lang.python#23992

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!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
 by: Stefan Ram - Fri, 15 Sep 2023 12:42 UTC

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...>

.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor