在Python 2.7.5:我如何繼承threading.Event?
from threading import Event
class State(Event):
def __init__(self, name):
super(Event, self).__init__()
self.name = name
def __repr__(self):
return self.name + '/' + self.is_set()
我得到:
TypeError: Error when calling the metaclass bases
function() argument 1 must be code, not str
爲什麼?
我知道threading.Event我從中學到的一切:http://docs.python.org/2/library/threading.html?highlight=threading#event-objects
是什麼意思時,它說,threading.Event()是類threading.Event一個工廠函數??? (呃......對我來說看起來很簡單)。
我剛剛發現http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python,目前正在閱讀它。 – Scruffy