-
Notifications
You must be signed in to change notification settings - Fork 7k
Closed
Labels
Description
I thought that the point of Borg was to allow subclassing. However, the implementation doesn't match expectations in this case:
class Borg:
__shared_state = {}
def __init__(self):
self.__dict__ = self.__shared_state
self.state = 'Running'
def __str__(self):
return self.state
instance0 = Borg()
instance1 = Borg()
instance0.state = 'Idle'
print instance1 # prints 'Idle', instead of 'Running', as expected
borg = Borg()
borg.state = 'Idle'
class YourBorg(Borg):
pass
borg = YourBorg()
print borg # prints 'Running' instead of 'Idle', **not** as expected
Are you sure that Borg supports setting attributes in the constructor ?
It looks like it defeats the purpose of Borg...