Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'argument': 0.04; 'subject:Python': 0.05; 'assign': 0.07; 'python': 0.09; 'declarations': 0.09; 'objects.': 0.09; 'subclass': 0.09; 'def': 0.10; 'static': 0.13; 'yet.': 0.13; ':-)': 0.13; 'value.': 0.15; '"global"': 0.16; 'bit.': 0.16; 'declaration': 0.16; 'definition.': 0.16; 'driscoll': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; "function's": 0.16; 'lambda': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'subject:Objects': 0.16; 'wrote:': 0.17; 'certainly': 0.17; 'exists': 0.17; '>>>': 0.18; 'versions': 0.20; 'comfortable': 0.20; 'java': 0.21; 'latter': 0.22; 'object.': 0.22; 'void': 0.22; 'class.': 0.23; "haven't": 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'actual': 0.28; 'python).': 0.29; 'received:192.168.1.3': 0.29; 'second,': 0.29; 'case,': 0.29; 'class': 0.29; "i'm": 0.29; 'function': 0.30; 'point': 0.31; '(and': 0.32; 'received:84': 0.32; 'certain': 0.33; 'turns': 0.33; 'to:addr:python-list': 0.33; 'code:': 0.33; "can't": 0.34; 'whatever': 0.35; 'pm,': 0.35; 'there': 0.35; 'but': 0.36; 'compare': 0.36; 'method': 0.36; 'does': 0.37; 'two': 0.37; 'far': 0.37; 'subject:: ': 0.38; 'from:': 0.38; 'object': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'takes': 0.39; 'received:192': 0.39; 'where': 0.40; 'received:192.168': 0.40; 'think': 0.40; 'most': 0.61; 'you.': 0.61; 'first': 0.61; 'kind': 0.61; 'warm': 0.62; 'show': 0.63; 'header:Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; "'foo'": 0.84; 'me;': 0.84; 'reply-to:addr:python.org': 0.84; 'fyi': 0.91; 'kat': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.0 cv=IekFqBWa c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=DKcI9XZsuF4A:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=bbxUIyF837gA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=R7Dkp_xKWAfitZrhRsEA:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117 X-AUTH: mrabarnett:2500 Date: Wed, 22 Aug 2012 21:31:51 +0100 From: MRAB User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Objects in Python References: <18409992-1e28-4721-8e64-60c69668da4e@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: python-list@python.org 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: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1345667508 news.xs4all.nl 6887 [2001:888:2000:d::a6]:48025 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:27683 On 22/08/2012 20:45, lipska the kat wrote: > On 22/08/12 20:03, Evan Driscoll wrote: >> On 08/22/2012 12:46 PM, lipska the kat wrote: >>> If you can show me a 'type' that cannot be assigned to >>> >>> a >>> >>> in the same scope then I would be most interested to know, I haven't >>> found one yet. >> > [snip] > >> >> Second, this concept isn't *so* unfamiliar to you. If I give you the >> following Java code: >> >> void foo(Object o) { ... } >> >> and ask what type 'o' is, there are kind of two answers. The first is >> that 'o' is an 'Object'. But you can't make an Object -- that's an >> abstract class. (IIRC. If it's not then just bear with me; you get the >> idea. :-)) So from a strictly static type-theory point of view, 'foo' is >> unusable because it takes a type which you can never create. But of >> course that's not the case, because in actual Java 'o' has some dynamic >> type which is a subclass of 'Object'. > > Well I think this is where I'm struggling a bit. > > looking at this method declaration I can see that the method takes an > argument of type Object (and just FYI class Object is not abstract and > you can do Object o = new Object()) and does not return a value. > I know that for the lifetime of this JVM, whatever o turns out to be it > will always be an Object. I can't assign a primitive to o as ints chars > floats etc are certainly not Objects. There are certain invariants that > give me a warm and comfortable feeling inside. > > compare this to a function declaration in Python > > def foo(self): > [snip] That's not actually a declaration but a definition. :-) The function's body is bound to the name at runtime, so: def double_it(x): return x * 2 is not far from: double_it = lambda x: x * 2 The only declarations are "global" and "nonlocal" (and the latter exists only in recent versions of Python).