[Python-Dev] Issue10403 - using 'attributes' instead of members in documentation
Michael Foord
fuzzyman at voidspace.org.uk
Tue Jun 28 15:25:13 CEST 2011
On 28/06/2011 13:56, Michael Foord wrote:
> On 28/06/2011 13:31, Nick Coghlan wrote:
>> On Tue, Jun 28, 2011 at 8:54 PM, Michael Foord
>> <fuzzyman at voidspace.org.uk> wrote:
>>> The problem with "data attributes" is that it doesn't mean
>>> *anything*, which
>>> I suppose is useful for invented terminology, but it means it
>>> doesn't convey
>>> anything precise to those who haven't heard the term before. If it
>>> becomes
>>> widely used then that changes I guess. I'd still normally just use
>>> "attributes" though...
>> In this context, precision is an illusion. There is *no* precise
>> terminology,
> "instance members" is precise, (whether or not an attribute is fetched
> "from the instance" is one thing that is clear in the python data
> model - there are just lots of other ways of fetching attributes too).
> "instance members" just doesn't cover all the cases where you may want
> to group attributes together though.
>
> However, providing "__getattr__" and "__getattribute__" is not the
> common case and even properties are *usually* backed by a real
> instance attribute. So "instance attributes" as opposed to other types
> of attributes is *often* a useful distinction.
>
> I don't think "data attributes" is clear or precise.
Although to be fair "data attributes" mirrors the terminology for
descriptors where we have "data descriptors" (which have both __set__
and __get__) and "non data descriptors" (__get__ only). Unfortunately
there are also non-non-data decriptors too (only __set__ and / or
__delete__) so that terminology is at least slightly confusing /
imprecise [1]... There was a genuine Python "bug" caused by that
confusion at one point (unfortunately I forget what it was).
All the best,
Michael
[1] From: http://users.rcn.com/python/download/Descriptor.htm
If an object defines both __get__ and __set__, it is considered a
data descriptor. Descriptors that only define __get__ are called
non-data descriptors (they are typically used for methods but other uses
are possible).
> Is a property a data attribute (well it depends how it is implemented
> and what it does), is a staticmethod a data attribute (no - but then
> Tres' question - it isn't a normal method either so if you define data
> attribute to mean "all non method attributes" then its potentially an
> open question).
>
> All the best,
>
> Michael Foord
>
>> not only because Python blurs the boundaries by design in
>> many respects (callable or not, method or not, attribute or not, etc),
>> but also because *people* use the same words to mean slightly
>> different things.
>>
>> The best we can hope for is to encourage the right way of thinking
>> about the situation, and in that regard you have the complete set of
>> attributes accessible via an object (i.e. via __getattribute__), some
>> of which are callables (and may or may not act like instance methods)
>> and the remainder of which are data attributes (some of which may
>> incidentally be callable, even if they aren't used that way). How a
>> *particular* attribute is classified is not an inherent property of
>> the attribute, but also an artifact of the way it is used by the
>> application.
>>
>> Cheers,
>> Nick.
>>
>
>
--
http://www.voidspace.org.uk/
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
More information about the Python-Dev
mailing list