My own list object

Nick Mathewson QnickQm at alum.mit.edu
Tue Feb 5 11:40:36 EST 2002


In article <a3p190$19v1rc$1 at ID-98166.news.dfncis.de>, MDK wrote:
> "Emile van Sebille" <emile at fenx.com> wrote in message
> news:a3p0ss$19ob7s$1 at ID-11957.news.dfncis.de...
 [...]
>> Call the method append and not __append__?
 [...]
> Yes, I figured that to be the case because it should be transparant to the
> caller.  However, that is not the solution.
> 
> Thanks though.

Really?  This works for me (under Python 2.2)


class newlist(list):
  def append(self, o):
    print "in subtype"

L = newlist( [1,2,3] )
print L
L.append(5)

#output:
#[1, 2, 3]
#in subtype

Yrs,

-- 
 Nick Mathewson    <Q nick Q m at alum dot mit dot edu>
                      Remove Q's to respond.  No spam.



More information about the Python-list mailing list