"Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Tue, 19 Jul 2005 10:20:04 +0200, Glauco wrote:
>
>>> The only niggly worry I have is I'm not sure when hash can be used,
>>> when
>>> it is unique, or even if is it guaranteed to be unique.
>>>
>>
>> Thank Steve,
Glauco,
Be careful if you decide to use hash.
There is possibility of bugs due to that approach, (if hash(x) == hash(y) and x != y).
Even if the probability of bug is near 0, your computer will certainly recall you what is the murphy law.
If I were you, I would prefer another approach.
Cyril
O
On Tue, 19 Jul 2005 10:20:04 +0200, Glauco wrote:
>> The only niggly worry I have is I'm not sure when hash can be used, when
>> it is unique, or even if is it guaranteed to be unique.
>>
>
> Thank Steve, the idea was the same...
> but yours using hash is much elegant.
I'm still worried about h
Steven D'Aprano wrote:
> On Mon, 18 Jul 2005 12:17:37 +0200, Glauco wrote:
>
>
>>I want to insert a concept of alias in a dict_based class.
>>
>>The idea is to have a facoltative name in the same dict that correspond
>>at the same value. With this alias i can change original value.
>>
>>example
I think "hash" doesn't guarantee the unicity of the result. But, it should avoid the collisions...
>>> foo = "foo"
>>> hash(foo)
-740391237
>>> hash(-740391237)
-740391237
I think it's like some kind md5sum...
I propose this solution:
---
On Mon, 18 Jul 2005 12:17:37 +0200, Glauco wrote:
> I want to insert a concept of alias in a dict_based class.
>
> The idea is to have a facoltative name in the same dict that correspond
> at the same value. With this alias i can change original value.
>
> example:
>
> mydict['a'] = 1
> I mus
Glauco wrote:
> I want to insert a concept of alias in a dict_based class.
...
> Any suggestion ?
Yes, in future don't attempt to start a new thread using "Reply" unless
you are happy not having your post read by all those who have already
"killed" the thread to which you replied. Anyone who wa
I want to insert a concept of alias in a dict_based class.
The idea is to have a facoltative name in the same dict that correspond
at the same value. With this alias i can change original value.
example:
mydict['a'] = 1
I must define an alias example: myFunctAlias( mydict, 'a', 'b')
print myd