Re: [Python-ideas] Add a way to test for a descriptor in Python Code

2018-10-30 Thread Joy Diamond
Clarifications: 1. I miswrote part of my first post where I wrote "I want to test if symbol found in __dict__ is an attribute or not in python code". I meant to write "is a DESCRIPTOR" or not. 2. The example in https://docs.python.org/3/howto/descriptor.html for reproducing `type.__getattribut

Re: [Python-ideas] Add a way to test for a descriptor in Python Code

2018-10-30 Thread Steven D'Aprano
On Tue, Oct 30, 2018 at 04:40:40AM -0400, Joy Diamond wrote: > """ > For classes, the machinery is in type.__getattribute__() which transforms > B.x into B.__dict__['x'].__get__(None, B). In pure Python, it looks like: > > def __getattribute__(self, key): > "Emulate type_getattro() in Objects

[Python-ideas] Add a way to test for a descriptor in Python Code

2018-10-30 Thread Joy Diamond
Greetings, I am trying to emulate attribute lookup, and want to test if symbol found in __dict__ is an attribute or not in python code (i.e.: does its have a `tp_descr_get` slot?) Reading the documentation carefully, I am supposed to test if the attribute has a `.__get__` method; however, I see n