Re: Difference method vs attribut = function

Liste des GroupesRevenir à cl python 
Sujet : Re: Difference method vs attribut = function
De : dieter.maurer (at) *nospam* online.de
Groupes : comp.lang.python
Date : 30. Jun 2024, 18:58:37
Autres entêtes
Message-ID : <mailman.183.1719771822.2909.python-list@python.org>
References : 1 2
User-Agent : VM 8.0.12-devo-585 under 21.4 (patch 24) "Standard C" XEmacs Lucid (x86_64-linux-gnu)
Ulrich Goebel wrote at 2024-6-28 18:08 +0200:
Hi,
>
a class can have methods, and it can have attributes, which can hold a function. Both is well known, of course.
>
My question: Is there any difference?

I think you should make the distinction "class versus instance attribute"
rather than "mether versus function".

If you look at the `__dict__` of an instance, you see only the
instance variables (the class's `__dict__` gives you the (most) attributes
of the class).

You can access (most) class attributes via an instance;
if a function is accessed in this way, it becomes (typically) a method.

Date Sujet#  Auteur
30 Jun 24 o Re: Difference method vs attribut = function1dieter.maurer

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal