Re: Subclassing list and splicing

2009-09-03 Thread Kreso
Kreso wrote: [...] > I would prefer that resulting object m belonged to myclist class. I forgot to add that mylist instances in my case have some attributes (that's why I need special container class in the first place) which should be preserved after splicing. In my simple underst

Re: Algorithms as objects?

2009-09-03 Thread Kreso
Bearophile wrote: > Please, can't you just use a bit of functional-style programming? Like > creating nested functions on the fly, etc. I thought about it but I believe that in the future some parts of the code will be reimplemented in C/C++, so I try to keep it simple. In the end the hint to le

Subclassing list and splicing

2009-09-03 Thread Kreso
I am subclassing list class and it basically works, but I don't understand why after splicing these mylist objects I don't get returned mylist objects. What I get are list objects: class mylist(list): def __init__(self): list.__init__(self) k = mylist() k.append(1) k.append(2) k.a

Algorithms as objects?

2009-08-27 Thread Kreso
I am writing an application that essentially calculates set of numbers, say N1, N2, ..., where they can be calculated by several different algorithms. (One should be able to choose the algorithm at run time.) In each algorithm one starts from a set of functions, say f1, f2, ..., which are then t

Re: Items inheriting attributes from its container?

2009-08-25 Thread Kreso
Jan Kaliszewski wrote: [...] Great! Thanks to all of you for advices and code. K. -- http://mail.python.org/mailman/listinfo/python-list

Items inheriting attributes from its container?

2009-08-22 Thread Kreso
I would like to create a list-like container class so that, additionally to usual list methods, I could attach attributes to the container instances. However, I would like it so that the items contained in the particular instance of container somehow 'inherit' those attributes i.e. cont = Containe