On Tue, 23 Aug 2011 17:25:22 +1000
Steven D'Aprano wrote:
> On Mon, 22 Aug 2011 11:08 pm John O'Hagan wrote:
>
> > On Mon, 22 Aug 2011 15:27:36 +1000
> > Steven D'Aprano wrote:
> [...]
> >> # Untested
> >> class MySeq(object):
> >> methods_to_delegate = ('__getitem__', '__len__', ...)
> >>
On Mon, 22 Aug 2011 20:38:30 +0200
Peter Otten <__pete...@web.de> wrote:
> John O'Hagan wrote:
>
> > On Mon, 22 Aug 2011 11:32:18 +0200
> > Peter Otten <__pete...@web.de> wrote:
> >
> >> John O'Hagan wrote:
> >>
> >> > I have a class like this:
> >> >
> >> > class MySeq():
> >> > def __ini
On Mon, 22 Aug 2011 11:08 pm John O'Hagan wrote:
> On Mon, 22 Aug 2011 15:27:36 +1000
> Steven D'Aprano wrote:
[...]
>> # Untested
>> class MySeq(object):
>> methods_to_delegate = ('__getitem__', '__len__', ...)
>> pitches = ... # make sure pitches is defined
>> def __getattr__(self,
On Tue, 23 Aug 2011 10:55 am John O'Hagan wrote:
>> > # Untested
>> > class MySeq(object):
>> > methods_to_delegate = ('__getitem__', '__len__', ...)
>> > pitches = ... # make sure pitches is defined
>> > def __getattr__(self, name):
>> > if name in self.__class__.methods_to_d
On Mon, 22 Aug 2011 23:08:50 +1000
John O'Hagan wrote:
> On Mon, 22 Aug 2011 15:27:36 +1000
> Steven D'Aprano wrote:
[..]
> > Looks like a call for (semi-)automatic delegation!
> >
> > Try something like this:
> >
> >
> > # Untested
> > class MySeq(object):
> > methods_to_delegate = ('__g
John O'Hagan wrote:
> On Mon, 22 Aug 2011 11:32:18 +0200
> Peter Otten <__pete...@web.de> wrote:
>
>> John O'Hagan wrote:
>>
>> > I have a class like this:
>> >
>> > class MySeq():
>> > def __init__(self, *seq, c=12):
>> > self.__c = c
>> > self.__pc = sorted(set([i % __c fo
On Mon, 22 Aug 2011 11:32:18 +0200
Peter Otten <__pete...@web.de> wrote:
> John O'Hagan wrote:
>
> > I have a class like this:
> >
> > class MySeq():
> > def __init__(self, *seq, c=12):
> > self.__c = c
> > self.__pc = sorted(set([i % __c for i in seq]))
> > self.orde
On Mon, 22 Aug 2011 15:27:36 +1000
Steven D'Aprano wrote:
> On Mon, 22 Aug 2011 03:04 pm John O'Hagan wrote:
>
> > The "pitches" attribute represents the instances and as such I found
> > myself adding a lot of methods like:
> >
> > def __getitem__(self, index):
> > return self.pitches[inde
John O'Hagan wrote:
> I have a class like this:
>
> class MySeq():
> def __init__(self, *seq, c=12):
> self.__c = c
> self.__pc = sorted(set([i % __c for i in seq]))
> self.order = ([[self.__pc.index(i % __c), i // __c] for i in seq])
> #other calculated attrib
On Mon, 22 Aug 2011 03:04 pm John O'Hagan wrote:
> The "pitches" attribute represents the instances and as such I found
> myself adding a lot of methods like:
>
> def __getitem__(self, index):
> return self.pitches[index]
>
> def __len__(self):
> return len(self.pitches)
Looks like a c
I have a class like this:
class MySeq():
def __init__(self, *seq, c=12):
self.__c = c
self.__pc = sorted(set([i % __c for i in seq]))
self.order = ([[self.__pc.index(i % __c), i // __c] for i in seq])
#other calculated attributes
@property
def pitches(s
11 matches
Mail list logo