Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: Is it correct this way to inherit from a list?

Reply
Thread Tools

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

 
 
Peter Otten
Guest
Posts: n/a
 
      03-02-2013
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 have added):
>
> from os.path import exists
>
> class vector(list):


> def __getitem__(self, key):
> return self._list[key]


[and many more]

> Is it correct or it exists another way to inherit from list class?


Have you considered subclassing collections.MutableSequence instead?
You cannot instantiate that class until you have overridden all its abstract
methods.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Is it correct this way to inherit from a list? Rick Johnson Python 3 03-03-2013 08:40 PM
Re: Is it correct this way to inherit from a list? Ian Kelly Python 0 03-02-2013 05:26 PM
Re: Is it correct this way to inherit from a list? Ian Kelly Python 0 03-02-2013 05:22 PM
How to get the correct size of inherit class? Zhou Fan C++ 4 03-23-2006 01:30 PM
Correct way to inherit from 3rd party class jonnytheclown Perl Misc 6 02-22-2005 05:51 PM



Advertisments