Hi,
 
I ran across a strange problem using mulitple inheritance that I hope someone can explain.  Basically, I am implementing a Publisher pattern, and when I try to add threading, the order I list Base classes matters!  Here is the short sample code-- all help explaining this is appreciated!
 
Thanks,
Marcus
 
---
import threading
 
class Publisher(object):
   def __init__(self): self.listeners = {} 
   def register(self, id, object):
      self.listeners[id] = self.listeners.get(id, object)
 
 
# This FAILS with AttributeError: 'FancyPublisher'
# object has no attribute 'listeners'
class FancyPublisher(threading.Thread, Publisher):
   def __init__(self):
      super(FancyPublisher, self).__init__()
 
F = FancyPublisher()
F.register('me', None)   
 
 
# However, this succeeds!?
class FancyPublisher(Publisher, threading.Thread):
   def __init__(self):
      super(FancyPublisher, self).__init__()
 
F = FancyPublisher()
F.register('me', None)   
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to