[Python-ideas] Sorry for yet another self discussion
Chris Barker
chris.barker at noaa.gov
Mon May 14 11:48:41 EDT 2018
> So I was thinking: why not do define the methods
> > like: "def self.whatevermethod(par1, par2, etc)" instead of "def
> > whatevermethod(self, par1, par2, etc)"?
>
because "self" in this case is a class instance, passed in at method call
time.
but "whatevermethod" is a class attribute.
note the distinction between the class object (shared by all instances) and
the instance object. I'm not saying the compiler couldn't make it work, but
I am saying that it would confuse the issue -- as it would not be defining
an attribute of self, even though it looks like it is.
-CHB
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180514/18372ac5/attachment.html>
More information about the Python-ideas
mailing list