@vytah: In Python, hash() returns an integer, and for objects with a __hash__ method, it uses the returned value. However, for performance reasons, Python may adjust the hash value of certain objects, like instances of custom classes. Specifically, Python ensures that hash values are not equal to -1 because -1 is used internally to indicate errors. Hence, hash(A()) becomes -2 instead of -1.
fajen bo udało się naprawić lapka, laptop 13 lat, wiatraczek głośnio chodził, chrzęścił, zamówiłem nowy, zamontowałem, wymieniłem też pastę na procku na nową i śmiga cichutko, temperaturki fajne, umiem coś
Głupia zagadka na dziś: co wypisze ten kod:
class A:def __hash__(self): return -1
print(hash(A()))
hash()returns an integer, and for objects with a__hash__method, it uses the returned value. However, for performance reasons, Python may adjust the hash value of certain objects, like instances of custom classes. Specifically, Python ensures that hash values are not equal to-1because-1is used internally to indicate errors. Hence,hash(A())becomes-2instead of-1.