Overloading the = operator?

Jerome Chan eviltofu at rocketmail.com
Sat Apr 22 20:14:02 EDT 2000


Is this possible?

class base:
   def __init__(self,q):
      self.list = q
   def __add__(self,other):
      # some type checking code
      return self.list + other.list

class another(base):
   def opr(self):
      # do something
      pass

class other(base):
   # do something too
   def work(self):
   pass

x = base([1,2])
y = another([2,4,3])

z = other([])

z = x + y
z.work()

where z now contains x.list + y.list???

I'm confused...



More information about the Python-list mailing list