Re: Is it correct this way to inherit from a list?

2013-03-03 Thread Colin J. Williams
On 02/03/2013 9:30 PM, gialloporpora wrote: Risposta al messaggio di Rick Johnson : What are you trying to achieve exactly? I would like to implement a class (vector) to works with vectors, for example using scalar multiplication: a*v = [a*v1, a*vn] and a dual class for dual vector (the

Re: Is it correct this way to inherit from a list?

2013-03-03 Thread Jason Swails
On Sun, Mar 3, 2013 at 9:21 AM, Colin J. Williams c...@ncf.ca wrote: On 02/03/2013 9:30 PM, gialloporpora wrote: Risposta al messaggio di Rick Johnson : What are you trying to achieve exactly? I would like to implement a class (vector) to works with vectors, for example using scalar

Is it correct this way to inherit from a list?

2013-03-02 Thread gialloporpora
Hi all, I would like to inherit from the list native class. really I expected that was possible to use native list method without redefining them, for example the __repr__ method. I don't know if i have made something wrong, this is my code (I obmit customized methods that I have added):

Re: Is it correct this way to inherit from a list?

2013-03-02 Thread Peter Otten
gialloporpora wrote: I would like to inherit from the list native class. really I expected that was possible to use native list method without redefining them, for example the __repr__ method. I don't know if i have made something wrong, this is my code (I obmit customized methods that I

Re: Is it correct this way to inherit from a list?

2013-03-02 Thread Ian Kelly
On Sat, Mar 2, 2013 at 10:22 AM, Ian Kelly ian.g.ke...@gmail.com wrote: class Vector(list): def __new__(cls, *args): return super(Vector, cls).__new__(cls, args) def __init__(self, *args): super(Vector, self).__init__(args) The __new__ method here will receive the

Re: Is it correct this way to inherit from a list?

2013-03-02 Thread Ian Kelly
On Sat, Mar 2, 2013 at 10:02 AM, gialloporpora gialloporp...@gmail.com wrote: Hi all, I would like to inherit from the list native class. really I expected that was possible to use native list method without redefining them, for example the __repr__ method. I don't know if i have made

Re: Is it correct this way to inherit from a list?

2013-03-02 Thread Rick Johnson
On Saturday, March 2, 2013 11:02:14 AM UTC-6, gialloporpora wrote: I would like to inherit from the list native class. really I expected that was possible to use native list method without redefining them, for example the __repr__ method. [...] class vector(list): def

Re: Is it correct this way to inherit from a list?

2013-03-02 Thread Chris Angelico
On Sun, Mar 3, 2013 at 1:30 PM, gialloporpora gialloporp...@gmail.com wrote: Risposta al messaggio di Rick Johnson : What are you trying to achieve exactly? I would like to implement a class (vector) to works with vectors, for example using scalar multiplication: a*v = [a*v1, a*vn] and