Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62193

Re: Type of an object:

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ethan@stoneleaf.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; '~ethan~': 0.09; 'def': 0.12; 'received:70.85.130': 0.16; 'received:70.85.130.22': 0.16; 'subject:object': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'see,': 0.30; '>>>>': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'class': 0.32; 'actual': 0.34; 'skip:_ 10': 0.34; 'info': 0.35; 'charset:us-ascii': 0.36; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:173': 0.61; 'believe': 0.68; "'test'": 0.84; 'subject::': 0.85
Date Tue, 17 Dec 2013 06:50:29 -0800
From Ethan Furman <ethan@stoneleaf.us>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: Type of an object:
References <mailman.4162.1387158693.18130.python-list@python.org> <52af7bfe$0$29976$c3e8da3$5496439d@news.astraweb.com> <mailman.4265.1387264469.18130.python-list@python.org> <52b0006a$0$29973$c3e8da3$5496439d@news.astraweb.com> <bhann0F1rrsU1@mid.individual.net>
In-Reply-To <bhann0F1rrsU1@mid.individual.net>
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - gator3304.hostgator.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - stoneleaf.us
X-BWhitelist no
X-Source-IP 173.12.184.233
X-Source
X-Source-Args
X-Source-Dir
X-Source-Sender ([173.12.184.233]) [173.12.184.233]:40072
X-Source-Auth ethan+stoneleaf.us
X-Email-Count 1
X-Source-Cap dG9idWs7dG9idWs7Z2F0b3IzMzA0Lmhvc3RnYXRvci5jb20=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4285.1387291826.18130.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1387291826 news.xs4all.nl 2861 [2001:888:2000:d::a6]:34221
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62193

Show key headers only | View raw


On 12/17/2013 02:35 AM, Gregory Ewing wrote:
> Steven D'Aprano wrote:
>> I think I need to see an actual working demonstration, because as far as I can see, type(obj) returns obj.__class__.
>
> Nope:
>
>>>> class C(object):
> ...  def f(self):
> ...   return "Surprise!"
> ...  __class__ = property(f)
> ...
>>>> c = C()
>>>> type(c)
> <class '__main__.C'>
>>>> c.__class__
> 'Surprise!'

I believe the proxying info comes into play with __class__.__name__:

--> class Test:
...   pass
...

--> t = Test()

--> type(t)
<class '__main__.Test'>

--> t.__class__
<class '__main__.Test'>

--> t.__class__.__name__
'Test'

--> t.__class__.__name__ = 'some_proxy'

--> t.__class__.__name__
'some_proxy'

--
~Ethan~

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Type of an object: ‘obj.__class__’ versus ‘type(obj)’ Ben Finney <ben+python@benfinney.id.au> - 2013-12-16 12:51 +1100
  Re: Type of an object: ‘obj.__class__’ versus ‘type(obj)’ Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-16 22:17 +0000
    Re: Type of an object: ‘obj.__class__’ versus ‘type(obj)’ dieter <dieter@handshake.de> - 2013-12-17 08:14 +0100
      Re: Type of an object: ‘obj.__class__’ versus ‘type(obj)’ Steven D'Aprano <steve@pearwood.info> - 2013-12-17 07:42 +0000
        Re: Type of an object: Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-12-17 23:35 +1300
          Re: Type of an object: Ethan Furman <ethan@stoneleaf.us> - 2013-12-17 06:50 -0800
          Re: Type of an object: Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-17 15:08 +0000
            Re: Type of an object: Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-12-18 11:15 +1300
              Re: Type of an object: Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-12-17 23:51 +0000
                Re: Type of an object: Ethan Furman <ethan@stoneleaf.us> - 2013-12-17 17:10 -0800
                Re: Type of an object: Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-12-19 00:45 +1300
                Re: Type of an object: Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2013-12-19 00:39 +1300

csiph-web