Re: [Pyobjc-dev] Bridging strings from Python to other languages
Brought to you by:
ronaldoussoren
From: Bill B. <bb...@co...> - 2003-02-05 22:37:53
|
That makes a lot of sense. In general, I would like to see Python move in the direction of supporting <character buffers> in an analagous/interchangeable fashion with <string>. This would make integration with external tools a lot easier. A part of that is doing exactly what you have indicated below -- when a string must be constant and there is a question as to whether or not the backing store for the string is mutable, provide a mechanism via which an immutable copy can be created. Nice. b.bum On Wednesday, Feb 5, 2003, at 17:34 US/Eastern, Just van Rossum wrote: > Just van Rossum wrote: > >> Python doesn't do anything special to "inbound" keys, it simply barfs >> when the key isn't hashable. > > Here's an idea: we could propose a new protocol for dicts that would > work like this: > > def __setitem__(self, key, value): > if not hashable(key): > if hasattr(key, "__immutablecopy__"): > key = key.__immutablecopy__() > else: > raise TypeError, "unhashable key" > ...insert value with key into dict... > > This might actually solve our problem nicely. Soonest for 2.3, though, > and even then we need to hurry. > > Just |