Singleton-like pattern

Carl Banks imbosol at aerojockey.com
Sun Aug 3 14:30:31 EDT 2003


Michele Simionato wrote:
> Steven Taschuk <staschuk at telusplanet.net> wrote in message news:<mailman.1059863764.14138.python-list at python.org>...
>> Quoth Michele Simionato:
>>   [...]
>> > Actually you are right, I remember now that I got problems with 
>> > (args,kw) and at the end I used args,tuple(kw.items()). But I was
>> > ensure if this was a good solution.
>> 
>> I'd worry about the order of kw.items().
> 
> Yes, indeed. Also, the args tuple can contain nested dictionaries and 
> become unhashable; in such a case I should recursively flatten all 
> the dictionaries to tuples, taking in account the ordering.
> To much work for me ...I have really to look at the cPickle solution.
> How does it solve the ordering issue? 


Unfortunately, not well.

>>> b = { 1: 1, 9: 1 }
>>> b
{1: 1, 9: 1}
>>> c = { 9: 1, 1: 1 }
>>> c
{9: 1, 1: 1}
>>> from cPickle import dumps
>>> dumps(b)
'(dp1\nI1\nI1\nsI9\nI1\ns.'
>>> dumps(c)
'(dp1\nI9\nI1\nsI1\nI1\ns.'



-- 
CARL BANKS
"You don't run Microsoft Windows.  Microsoft Windows runs you."




More information about the Python-list mailing list