What's wrong with it?
lee lion
dance_code at hotmail.com
Mon Sep 30 11:12:38 EDT 2002
Hi, What's wrong with it?
class Borg(object):
_shared_state = {}
def __new__(cls):
return cls._shared_state
class Singleton(Borg):
def __new__(cls, arg):
self = Borg.__new__(cls)
self['val'] = arg
return self
def main():
x = Singleton('sausage')
[snip]
When running:
>>>
Traceback (most recent call last):
File "D:\Programming\Python22\my_Python_programs\MyBorgSingleton.py",
line 27, in ?
main()
File "D:\Programming\Python22\my_Python_programs\MyBorgSingleton.py",
line 16, in main
x = Singleton('sausage')
ValueError: dictionary update sequence element #0 has length 1; 2 is
required
Could anyone tell me why it broke with that strange runtime error?
Thank in advance,
Lion
"The best way of living is to earn a little more than you cost and to cost
just as you need to."
Li Hang
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger:
http://messenger.microsoft.com/cn/
More information about the Python-list
mailing list