A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2005-November/057952.html below:

[Python-Dev] For Python 3k, drop default/implicit hash, and comparison

[Python-Dev] For Python 3k, drop default/implicit hash, and comparisonTechnical Support of Intercable Co support at intercable.ru
Tue Nov 8 08:59:42 CET 2005
Why 'identity' objects can't define:
    def __getKey__(self):
         return Key(self, id(self))
Then they would act as usually, while value object can define
    def __getKey__(self):
         return Key(self, self.i, self.j, self.a[1])

(Key is an abstraction to handle subclassing)

Of course, there should be a way to handle comparison off the class 
ierarhy (i think)
Today one can write:
 >>> class Boo(object):
    def __init__(self,s=""):
       self.s=s
    def __hash__(self):
       return hash(self.s)
    def __cmp__(self,other):
       if type(self)==type(other):
          return cmp(self.s,other.s)
       if type(other)==str:
          return cmp(self.s,other)
 >>> a={}
 >>> a['s']=1
 >>> a[Boo('s')]
1
 >>> a[Boo('z')]=2
 >>> a['z']
2
It is confused and hardly usefull, but possible.

Excuse my english.

More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4