> To: tutor@python.org
> From: __pete...@web.de
> Date: Fri, 13 Nov 2015 09:26:55 +0100
> Subject: Re: [Tutor] question about descriptors
>
> Albert-Jan Roskam wrote:
>
> >> __getattr__() is only invoked as a fallback when the normal attribute
> >> lookup
On Thu, Nov 12, 2015 at 12:11:19PM +, Albert-Jan Roskam wrote:
> > __getattr__() is only invoked as a fallback when the normal attribute
> > lookup
> > fails:
>
>
> Aha.. and "normal attributes" live in self.__dict__?
Not necessarily.
Attributes can live either in "slots" or the
Albert-Jan Roskam wrote:
>> __getattr__() is only invoked as a fallback when the normal attribute
>> lookup fails:
>
>
> Aha.. and "normal attributes" live in self.__dict__?
I meant "normal (attribute lookup)" rather than "(normal attribute) lookup".
__getattr__() works the same (I think) when
> To: tutor@python.org
> From: __pete...@web.de
> Date: Wed, 11 Nov 2015 20:06:20 +0100
> Subject: Re: [Tutor] question about descriptors
>
> Albert-Jan Roskam wrote:
>
> >> From: st...@pearwood.info
>
> >> Fortunately, Python has an mechanism for s
> Date: Sun, 8 Nov 2015 01:24:58 +1100
> From: st...@pearwood.info
> To: tutor@python.org
> Subject: Re: [Tutor] question about descriptors
>
> On Sat, Nov 07, 2015 at 12:53:11PM +, Albert-Jan Roskam wrote:
>
> [...]
> > Ok, now to my question. I want to
Albert-Jan Roskam wrote:
>> class ReadColumn(object):
>> def __init__(self, index):
>> self._index = index
>> def __get__(self, obj, type=None):
>> return obj._row[self._index]
>> def __set__(self, obj, value):
>> raise AttributeError("oops")
>
> This appears
Albert-Jan Roskam wrote:
>> From: st...@pearwood.info
>> Fortunately, Python has an mechanism for solving this problem:
>> the `__getattr__` method and friends.
>>
>>
>> class ColumnView(object):
>> _data = {'a': [1, 2, 3, 4, 5, 6],
>> 'b': [1, 2, 4, 8, 16, 32],
>>
> I think the basic misunderstandings are that
>
> (1) the __get__() method has to be implemented by the descriptor class
> (2) the descriptor instances should be attributes of the class that is
> supposed to invoke __get__(). E. g.:
>
> class C(object):
>x = decriptor()
>
> c = C()
>
Albert-Jan Roskam wrote:
>
>
> p, li { white-space: pre-wrap; }
>
> Hi,
> First, before I forget, emails from hotmail/yahoo etc appear to end up in
> the spam folder these days, so apologies in advance if I do not appear to
> follow up to your replies. Ok, now to my question. I want to create
On 07/11/15 12:53, Albert-Jan Roskam wrote:
Ok, now to my question.
> I want to create a class with read-only attribute access
to the columns of a .csv file.
Can you clarify what you mean by that?
The csvreader is by definition read only.
So is it the in-memory model that you want
On Sat, Nov 07, 2015 at 12:53:11PM +, Albert-Jan Roskam wrote:
[...]
> Ok, now to my question. I want to create a class with read-only
> attribute access to the columns of a .csv file. E.g. when a file has a
> column named 'a', that column should be returned as list by using
> instance.a.
11 matches
Mail list logo