[Python-Dev] PEP 447: add type.locallookup (original) (raw)
Steven D'Aprano steve at pearwood.info
Fri Sep 13 14:23:28 CEST 2013
- Previous message: [Python-Dev] PEP 447: add type.__locallookup__
- Next message: [Python-Dev] PEP 447: add type.__locallookup__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Sep 13, 2013 at 08:42:46PM +1000, Nick Coghlan wrote:
Perhaps "getdescriptor" would work as the method name? Yes, it can technically return a non-descriptor,
So technically that name is, um, what's the term... oh yes, "a lie".
:-)
but the primary purpose is to customise the retrieval of objects that will be checked to see if they're descriptors.
If that's the case, the PEP should make that clear.
[Aside: the PEP states that the method shouldn't invoke descriptors. What's the reason for that? If I take the statement literally, doesn't it mean that the method mustn't use any other methods at all? Surely that can't be what is intended, but I'm not sure what is intended.]
It won't be invoked when looking for ordinary attributes in an instance dict, but will be invoked when looking on the class object.
Just to be clear, if I have:
instance = MyClass() x = instance.name
and "name" is found in instance.dict, then this special method will not be invoked. But if "name" is not found in the instance dict, then "name" will be looked up on the class object MyClass, which may invoke this special method. Am I correct?
-- Steven
- Previous message: [Python-Dev] PEP 447: add type.__locallookup__
- Next message: [Python-Dev] PEP 447: add type.__locallookup__
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]