Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #62293
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Type of an object: |
| Date | 2013-12-19 00:39 +1300 |
| Message-ID | <bhdfrdFjo0gU1@mid.individual.net> (permalink) |
| References | (3 earlier) <52b0006a$0$29973$c3e8da3$5496439d@news.astraweb.com> <bhann0F1rrsU1@mid.individual.net> <52b06902$0$29976$c3e8da3$5496439d@news.astraweb.com> <bhc0n9Fan00U1@mid.individual.net> <52b0e36b$0$6512$c3e8da3$5496439d@news.astraweb.com> |
Steven D'Aprano wrote: > It's the *non-class* part I reckon is an accident, or a bug. Telling me > that weakproxy sets __class__ to a *class* doesn't argue for or against > me. I wouldn't describe what weakref.proxy is doing as *setting* __class__ to anything. Rather, it's arranging things so that when you *get* x.__class__, it returns something other than type(x). And I expect it's achieving that effect by exploiting one of the general mechanisms available for overriding attribute access. You seem to think it's an "accident" that there is no protection in place to prevent __class__ access from being overridden in such a way that it returns something other than a class. I suppose you could say that this "works by accident", but I would say that it simply works. There may not be any obvious practical *use* for it, but it's not worth anyone's time to go out of their way to prevent it. -- Greg
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll 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