Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.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.047 X-Spam-Evidence: '*H*': 0.91; '*S*': 0.00; 'output': 0.05; '21,': 0.07; '*args,': 0.09; 'def': 0.12; '**kwargs)': 0.16; '**kwargs):': 0.16; 'name):': 0.16; 'output?': 0.16; 'wrote:': 0.18; 'thu,': 0.19; '>>>': 0.22; 'aug': 0.22; 'email addr:gmail.com>': 0.22; 'header:User-Agent:1': 0.23; '>>>': 0.24; 'instance,': 0.24; 'question': 0.24; 'source': 0.25; '>': 0.26; 'skip:_ 20': 0.27; 'header:In-Reply- To:1': 0.27; 'to:2**1': 0.27; 'code': 0.31; "skip:' 10": 0.31; 'class': 0.32; 'are:': 0.33; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'received:google.com': 0.35; 'there': 0.35; 'method': 0.36; 'received:10': 0.37; 'skip:o 20': 0.38; 'message-id:@gmail.com': 0.38; 'skip:& 10': 0.38; '8bit%:4': 0.38; 'work?': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'does': 0.39; '\xa0\xa0\xa0': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'called': 0.40; '8bit%:6': 0.40; 'ian': 0.60; 'tell': 0.60; "you're": 0.61; 'name': 0.63; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'charset:windows-1252': 0.65; '7:25': 0.84; '8bit%:16': 0.84; 'x):': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type; bh=Bs5cAfDuC8bBNH6w99KoJ2zhTqeWagkiddatqKKubjc=; b=h+FAiOqpfuNmhQXB/iYgmufkhyY5wGPbhHMJVzKXbm9WYihGsVw7UDJPrpFIACavd2 1i9aJpbpTeioEKIDUlkiMPhpxd41gAePL45L/jY03ovKwrB27Vck+ACVpt8z9jb8EZpn rd7BhGWnyjg5WhivCiJ9d93PocPFXTzvNSMf+3lRxv1m8ezyVhCYWVzoYTqBgnwyo+Eg uIIS9TrDu4mnFPLe7GqfDeI//VP92IDRJTTFbyXhpfrQCCAeeYrf8Pnj5W+3C5mzbDHO bK8uDf2G9F8N/eTpnmoIfKeKbpyuKDEaB2ueQmM/mvO4KyUY4ZqrcpQ51u7kG/Yu0Hmc vAUg== X-Received: by 10.70.95.34 with SMTP id dh2mr17220463pdb.119.1408850618807; Sat, 23 Aug 2014 20:23:38 -0700 (PDT) Date: Sun, 24 Aug 2014 11:23:28 +0800 From: luofeiyu User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: Ian Kelly , python-list@python.org Subject: Re: the output in reference of descriptor. References: <53F69BEE.5000000@gmail.com> In-Reply-To: Content-Type: multipart/alternative; boundary="------------050101070700080803020003" 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: 179 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1408850628 news.xs4all.nl 2888 [2001:888:2000:d::a6]:43354 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:76921 This is a multi-part message in MIME format. --------------050101070700080803020003 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit let me paste it again to make my question more clear: >>>c2.d __get__() is called <__main__.C2 object at 0x000000000297BE10> <__main__.C object at 0x000000000297BBA8> >>> c2.d.a __get__() is called <__main__.C2 object at 0x000000000297BE10> __getattribute__() is called 'abc' Why the result of c2.d.a is not : __get__() is called <__main__.C2 object at 0x000000000297BE10> <__main__.C object at 0x000000000297BBA8> __getattribute__() is called 'abc' Why the` return self` in the __get__ method in class C does not work? Why there is no <__main__.C object at 0x000000000297BBA8> in the output? and the source code are: |class C(object): a = 'abc' def __getattribute__(self, *args, **kwargs): print("__getattribute__() is called") return object.__getattribute__(self, *args, **kwargs) def __getattr__(self, name): print("__getattr__() is called ") return name + " from getattr" def __get__(self, instance, owner): print("__get__() is called", instance, owner) return self def foo(self, x): print(x) class C2(object): d = C() | On 8/23/2014 12:10 PM, Ian Kelly wrote: > On Thu, Aug 21, 2014 at 7:25 PM, luofeiyu > wrote: > > >>> c2.d.a > > __get__() is called <__main__.C2 object at 0x000000000297BE10> > > C2'> > > __getattribute__() is called > > 'abc' > > > > Why the result of c2.d.a is not : > > > > __get__() is called <__main__.C2 object at 0x000000000297BE10> > > C2'> > > __getattribute__() is called > > 'abc' > > As far as I can tell you pasted the same output twice, so I don't > understand what it is that you're asking. > > > > --------------050101070700080803020003 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 8bit let me paste it again to make my question more clear:

    >>>c2.d 
    __get__() is called <__main__.C2 object at 0x000000000297BE10> <class '__main__.C2'> 
    <__main__.C object at 0x000000000297BBA8> 

    >>> c2.d.a 
    __get__() is called <__main__.C2 object at 0x000000000297BE10> <class '__main__.C2'> 
    __getattribute__() is called   
    'abc' 
 
Why the result of c2.d.a  is not :  
 
    __get__() is called <__main__.C2 object at 0x000000000297BE10> <class __main__.C2'>   
    <__main__.C object at 0x000000000297BBA8>     
    __getattribute__() is called     
    'abc'     
 
Why the` return self` in the __get__ method in class C  does not work? Why there is no <__main__.C object at 0x000000000297BBA8>  in the output?


and the source code are:


class C(object):  
    a = 'abc'  
    def __getattribute__(self, *args, **kwargs):  
        print("__getattribute__() is called")  
        return object.__getattribute__(self, *args, **kwargs)  
    def __getattr__(self, name):  
        print("__getattr__() is called ")  
        return name + " from getattr"  
    def __get__(self, instance, owner):  
        print("__get__() is called", instance, owner)  
        return self  
    def foo(self, x):  
        print(x)  


class C2(object):  
    d = C() 



On 8/23/2014 12:10 PM, Ian Kelly wrote:
On Thu, Aug 21, 2014 at 7:25 PM, luofeiyu <elearn2014@gmail.com> wrote:
> >>> c2.d.a
> __get__() is called <__main__.C2 object at 0x000000000297BE10> <class '__main__.
> C2'>
> __getattribute__() is called
> 'abc'
>
> Why the result of c2.d.a  is not :
>
> __get__() is called <__main__.C2 object at 0x000000000297BE10> <class '__main__.
> C2'>
> __getattribute__() is called
> 'abc'

As far as I can tell you pasted the same output twice, so I don't understand what it is that you're asking.





--------------050101070700080803020003--