why is self not passed to id()?

Ruediger larudwer at freenet.de
Thu Sep 4 16:26:53 EDT 2008


Hello!

Executing following little program gives me an TypeError.

What makes me wonder is that foo does get an argument passed while bar
doesn't. Can anyone explain why??????

Thanks
Ruediger



class foo(list):
    __hash__ = lambda x: id(x)

class bar(list):
    __hash__ = id

_s_ = set()
_s_.add(foo())
_s_.add(bar())

rue at linux:~> python test01.py
Traceback (most recent call last):
  File "test01.py", line 9, in <module>
    _s_.add(bar())
TypeError: id() takes exactly one argument (0 given)




More information about the Python-list mailing list