Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'classes,': 0.05; 'subject:Python': 0.06; 'class,': 0.07; 'convention.': 0.07; 'builtin': 0.09; 'instance.': 0.09; 'method,': 0.09; 'parameter': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'required,': 0.09; 'spelling': 0.09; 'python': 0.11; 'def': 0.12; 'jan': 0.12; 'behavior,': 0.16; 'fishing': 0.16; 'illustrate': 0.16; 'lowercase': 0.16; 'o):': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'responses.': 0.16; 'subject:Classes': 0.16; 'user-defined': 0.16; 'wrote:': 0.18; 'code,': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'refers': 0.24; 'class.': 0.26; 'pass': 0.26; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'usually': 0.31; 'object.': 0.31; 'anyone': 0.31; 'class': 0.32; 'classes': 0.35; 'except': 0.35; 'definition': 0.35; 'but': 0.35; 'method': 0.36; 'step': 0.37; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'received:71': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'called': 0.40; 'john': 0.61; 'first': 0.61; 'such': 0.63; 'soon': 0.63; 'within': 0.65; 'fact,': 0.69; "'object'": 0.84; 'received:fios.verizon.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Python Classes Date: Mon, 04 Aug 2014 19:26:20 -0400 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-71-175-90-87.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 36 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1407194809 news.xs4all.nl 2842 [2001:888:2000:d::a6]:47880 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:75714 On 8/4/2014 6:44 PM, John Gordon wrote: > __init__() is the initializer method, which is called as one step of > creating a class object. In fact, it is the last step and usually is the main step for user-defined classes, and the only step one need be concerned with. > Object is the lowest-level class. All other classes inherit from Object. The spelling is 'object', with lowercase 'o'. 'Object' would have been less confusing, but all other builtin classes, are lowercase (some because they started as functions in Python 1.0 or soon thereafter). > Within a class, self is a reference to the current class instance. This is only true within a method definition and only when 'self' is given as the first parameter name. class C: def meth_standard(self, other): pass # 'self' is an object of class C, 'other' to any other object. # Using 'self' is not required, but is the standard convention. def meth_brief(s, o): pass # 's' refers to an instance of class C, 'o' to any other object # ok for quick interactive use that one keeps private def meth_obnoxious(other, self): pass # 'other' is an instance of C, 'self' is any object # Anyone who publishes such code, except to illustrate trollish # behavior, is fishing for heated responses. -- Terry Jan Reedy