Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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; 'syntax': 0.03; 'builtin': 0.07; 'classes.': 0.07; 'except:': 0.07; 'executed': 0.07; 'interpreted': 0.07; 'method,': 0.07; 'operand': 0.07; 'try:': 0.07; 'python': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; 'language': 0.14; '*you*': 0.16; 'background,': 0.16; 'callables': 0.16; 'message- id:@dough.gmane.org': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'wrote:': 0.17; 'certainly': 0.17; 'integer': 0.17; 'jan': 0.18; 'equivalent': 0.20; 'explicit': 0.22; 'oriented': 0.22; 'defined': 0.22; 'nearly': 0.23; "python's": 0.23; 'seems': 0.23; 'raise': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'wrote': 0.26; 'am,': 0.27; 'plain': 0.27; 'header:X-Complaints-To:1': 0.28; 'slot': 0.29; 'wrap': 0.29; 'checks': 0.30; 'getting': 0.33; 'int': 0.33; 'to:addr:python- list': 0.33; 'done': 0.34; 'sequence': 0.35; 'something': 0.35; 'received:org': 0.36; 'but': 0.36; 'skip:{ 10': 0.36; 'method': 0.36; 'moment': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'object': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'most': 0.61; 'subject:, ': 0.61; 'interest': 0.62; 'six': 0.65; 'ago.': 0.66; 'believe': 0.69; 'special': 0.73; 'forced': 0.84; 'received:fios.verizon.net': 0.84; 'type(s)': 0.84; 'kat': 0.91; 'subject:skip:E 10': 0.95 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: Encapsulation, inheritance and polymorphism Date: Thu, 19 Jul 2012 02:11:23 -0400 References: <3vnfd9-343.ln1@satorlaser.homedns.org> <-8SdnVrXGqie25jNnZ2dnUVZ7qKdnZ2d@bt.com> <5005A103.9050802@stoneleaf.us> <5006b48a$0$29978$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20120614 Thunderbird/13.0.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 41 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1342678307 news.xs4all.nl 6990 [2001:888:2000:d::a6]:40186 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:25609 On 7/18/2012 10:40 AM, Lipska the Kat wrote: > fact ... and I have never been forced to admit that I don't know what I > wrote six months ago. That is an explicit objective of Python's design. > Python looks like an interesting language and I will certainly spend > time getting to know it but at the moment it seems to me that calling it > an Object Oriented language is just plain misleading. I just call it object-based and let be done with it, as I have no interest in arguing 'Object Oriented'. What perhaps *you* need to know, given your background, is that nearly all syntax and most builtin callables wrap special method calls that can be defined on user classes. 'a + b' is executed as something like try: return a.__add__(b) # or the C type slot equivalent except: # not sure what is actually caught try: return b.__radd__(a) # r(everse)add except: # ditto raise TypeError("unsupported operand type(s) for +: {} and {}".format(a, b)) [Syntax exceptions: =, and, or] 'len(x)' calls x.__len__ and checks that the return value can be interpreted as an integer (I believe that means that it is an int or has an __index__ method, so that it can be used as a sequence index) and that its value is >= 0. -- Terry Jan Reedy