Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Pause for storage relocation.


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

SubjectAuthor
o Re: Why doc call `__init__` as a method rather than function?scruel tao

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

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

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!news-2.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: scru...@hotmail.com (scruel tao)
Newsgroups: comp.lang.python
Subject: Re: Why doc call `__init__` as a method rather than function?
Date: Mon, 18 Sep 2023 10:43:20 +0000
Lines: 44
Message-ID: <mailman.328.1695033805.23016.python-list@python.org>
References: <OS3P286MB0740BDD307B9BEB732BD2256A5F6A@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
<6a907429.54af.18a98f21d8d.Webtop.90@btinternet.com>
<fb6b5ac0-bb63-4aca-a8ef-c3eca2097058@roelschroeven.net>
<OSZP286MB0742282CDF6B2B68B4A12569A5FBA@OSZP286MB0742.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 cmS/JoABXIJYSkE+GSnJ0A6yvZKNfo9OwqnGh0mKGkxA==
Cancel-Lock: sha1:lnX4qeFaEMAOwuRPQLK/ONd0HjY= sha256:nbRLmyYvXBZrFk9Sb+tSeDV7o4Yz78Gbb4n5tGOU4is=
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=AJ9FDAsj;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.003
X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'explanation': 0.07;
'subject:Why': 0.07; 'used.': 0.07; 'instances': 0.09; 'meant':
0.09; 'methods,': 0.09; 'skip:` 10': 0.09; '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;
'user.': 0.09; '&gt;': 0.14; '(oop)': 0.16; 'classes,': 0.16;
'development,': 0.16; 'functions,': 0.16; 'interface,': 0.16;
'mentioned,': 0.16; 'object,': 0.16; 'procedure': 0.16;
'resolved,': 0.16; 'rule"': 0.16; 'static': 0.16; 'subject:call':
0.16; 'to:addr:python-list': 0.20; 'code': 0.23; 'to:name:python-
list@python.org': 0.24; 'discussion': 0.25; 'section': 0.25;
'programming': 0.25; 'behavior': 0.26; 'object': 0.26; 'function':
0.27; 'computer': 0.29; 'think': 0.32; 'everyone': 0.32;
'question': 0.32; 'here,': 0.32; 'mark': 0.32; 'but': 0.32;
'header:In-Reply-To:1': 0.34; '"the': 0.35; 'following': 0.35;
'functions': 0.36; 'really': 0.37; 'class': 0.37; 'though': 0.37;
'url-ip:13.107/16': 0.38; 'thanks': 0.38; 'use': 0.39; 'methods':
0.39; 'still': 0.40; 'charset:windows-1252': 0.60; 'method': 0.61;
'skip:o 10': 0.61; 'miss': 0.62; "you'd": 0.64; 'your': 0.64;
'daily': 0.65; '&amp;': 0.65; 'back': 0.67; 'caught': 0.67;
'generally': 0.67; 'url-ip:104.18/16': 0.67; 'subject:method':
0.69; 'depending': 0.70; 'relevant': 0.73; 'languages,': 0.76;
'field,': 0.84; 'subject:than': 0.91; 'consists': 0.93
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=LWC0va44WXHre7wr7DZNrdVmrdBV/RsssiMkEZgdaAKrx1bMgtaBCjChRbAfh9STlc4z0qxOcGohw2xS0Vk/Xm/Cc5PtgdWXUiaAws9yUiSY1TCaDI3xGLe4+tuJDmOBjMAD4Ot7Jf/v3vSy7xtbPzcqDxPn7XpccR07ZDDfB0FyLJq+tee9eFGavYBVlwBeXFE69CrzaxaGuLmy6s1frrxelAHf66cyLBNgu1fClEir55gbQqplB/KjEdyTBArri+/ZnFMH21l4/s7oEypn4KUML/HxgYLMzr1vv5zw4+0g0u09lnn75N8ChOZdGuZfbMk9GS+IbdI7WY8VLLL6ZQ==
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=QeLsU2LRh26NwPjgIhXsxX+o+nkU8C0QEPdo4aSCfdM=;
b=mhul3XxY3o4tLRcT9laDPnb1i9cAJ7pcLx93Uovs0BXAbNmqBl1k3Of3AUwuKRlEOu9VQFp6bAUCVQHx6vWbu1820ZPPxB94ew2WhgqR/i3JwutpC4DbNqk+MAJrRdoZPZhjaDLPPwqSFoa/4IdCQ1nz1+ARuiR22hNIDfIT9mMLQ8SK/XGi9LeO8MgddxDd0HO/RV57A5EoyrGyhDmkjfxoDWgYc2NZiym6RNB9+slP2Jzed5CT+LV1wFI/QE7ETZJhh6G4clog616mrwI01/3/NeehwLhGoOTZQE+3uWkno23MaEIq/2b45qc+D9wtF3ZP+NSrws+kz60UL+D+VQ==
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=QeLsU2LRh26NwPjgIhXsxX+o+nkU8C0QEPdo4aSCfdM=;
b=AJ9FDAsjRNT/GKyTFV0hZX1CCXtscB5Tyd7WRl51pk1OWvF2SRABHYG5hAZ28/w/0BjhF/ST75welELgnDLlNzd1rqXZcDrV3latOQ+WbxsKvQOe3Gk2tzlRE68kYvfdLtjpCHyA47pPeDiTFHUz5KVuIIetZisGY0C0gAM7HCjPDYhfBaTD3jhc/b58Mn4C81HtaDRNLAygfyvkd3qUpJO7BBPuvFHx62gsd0bk0MmYApDtJjx3zw2cr8zVsyhgkCiDNwsf72r9Hiza2M0Qo6jQ4w/5vVIBNMhnJy/lwK/91+0ALM50KPQ9Mi7ngbgFJ63ccmlQGxqhNqHO3nzYGg==
Thread-Topic: Why doc call `__init__` as a method rather than function?
Thread-Index: AQHZ58BrZpWMmMM+jEWDF+LlUUfVarAb2wwAgARnDwCAABoLLw==
In-Reply-To: <fb6b5ac0-bb63-4aca-a8ef-c3eca2097058@roelschroeven.net>
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: [yp43Ck8nd2oqnH5gj0BozankJFLVpNVkZMgRAKXiY9U=]
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: OSZP286MB0742:EE_|TYCP286MB3655:EE_
x-ms-office365-filtering-correlation-id: 87c3b888-71d4-4fc5-b9bb-08dbb8341337
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: Au+EKNIgJYQM5y1pn/w1Fx46e9cqpuoDYxHW32KxS/0PkpMuF7FMHq8F3MrAP6mJcYpoJU5HplJg3Qrbzhm759qGZf6z+XhKl11ootCWH2S69/ry8u7QJIZNdpy7XKz/2qSRYCHidmUm0O4xThbhqTD9qsdspubT6tvP4TTP7H0VJx5qrilDtetnf1WsWMcO7Ey2UfiyDFG533S1PtPnYeUVSDJhQKTXGPocSvlZzWu1QS9ggGTjMKEAJZS1Y8OHthqjjJhS6AyzeKn0NeylpkWGBw9dP5NxtoKYi3EtClIezPqs3NMbmsinJXHCclQhw2Mh7ZQcQaAeT1dmM3zAvoiv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JldYH7Ffq3FGzC391lYwQ8JtpxgkIUxHX775JwM9aPVQ0KnrBNf
xeXVIww7jwqr2I9zWjLVZtlG1kHczLnndFiWr4co5gi+GN7aWufpvNFC
TgKRrPDVLVvyK5pzunfc9fLSCeml+yvaaI3cjU3eZOGmmnEVIITBTIJ4
kgjJnEH7Kh1uA6ILMwzF5tujVZ1OXnQDHOfjwpQ6asRr8mAvDL3Na2Di
HW11AEYvjkfa6PBWyJ1m4ej3RMrtEJgC5HCY4o2nKoDJZKO+CgCKyCgH
mT0gmaFlvM9+HsoL1Ki9BmHawokkmkd9SYH1tv1sRz/lrJaS8fTuEjph
U3KMzjF5LJ8hP+LiRDbsxe2qeLJJYSlV7C2OjqxuVDgQVQ7dAoRWdpRf
ur1Yw6WIYLLcig23ERZHDAvwW4eya449aTjuEY9428XDqBqtJMoOWdk5
ZZd92nkAO7w8hUFsm/XdxMOrvUQ=
X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-05f45.templateTenant
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: OSZP286MB0742.JPNP286.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-Network-Message-Id: 87c3b888-71d4-4fc5-b9bb-08dbb8341337
X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Sep 2023 10:43:20.3123 (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: TYCP286MB3655
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: <OSZP286MB0742282CDF6B2B68B4A12569A5FBA@OSZP286MB0742.JPNP286.PROD.OUTLOOK.COM>
X-Mailman-Original-References: <OS3P286MB0740BDD307B9BEB732BD2256A5F6A@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
<6a907429.54af.18a98f21d8d.Webtop.90@btinternet.com>
<fb6b5ac0-bb63-4aca-a8ef-c3eca2097058@roelschroeven.net>
 by: scruel tao - Mon, 18 Sep 2023 10:43 UTC

Thanks for all repliers:
@Tony & @Cameron, I do know related stuffs about the dunder methods, and your explanation just make it to be more clear, thank you!
@Roel, you just caught everyone here, we do miss it even though we know it and use it regularly!

@Clara
> its both, depending on how you're getting it.
Might can be more clear: its both, depending on how you're using/getting it..

And I think I can mark this question as resolved, and with the following conclusions:
As @Clara mentioned, we need to know that "all methods are functions", so we do can call `__init__` as a method or a function, or we can be avoid to have such discussion like Dan, and call it "the initializer" (However, you will need to think about “what is this is” for other functions :). ).
As @Alan mentioned, and according to the Wikipedia, in computer programming field, "method" is:
> A method in object-oriented programming (OOP) is a procedure associated with an object, and generally also a message. An object consists of state data and behavior; these compose an interface, which specifies how the object may be used. A method is a behavior of an object parametrized by a user.

For `__init__` and other functions in classes, we usually use them by writing code `obj.action()`, so we usually will call them as methods, so here, we call `action` or `__init__` as a method.
However, if you use them by writing code `Clz.action(obj)`, then you'd better (or must?) to call them as functions, and it is not a "daily use case" in daily development, and in some languages, this behavior won't even be possible.
**So, its kinda a "Majority rule" to call `__init__` (functions in classes) as a method.**

==BTW, in Wikipedia, the "static methods" section is a very interesting:
> Static methods are meant to be relevant to all the instances of a class rather than to any specific instance.
This explanation might can "group" some functions back to "methods" :) However, let's still remember:
All methods are functions, but not every function is a method.

Thanks again for helping, you guys are really nice!

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor