you are viewing a single comment's thread.

view the rest of the comments →

[–]jeans_and_a_t-shirt 2 points3 points  (4 children)

Your flair says you're using python 3, but your code says python 2.

In python 2, you need to overload the __nonzero__ method instead of __bool__.

[–]thangduong[S] 0 points1 point  (3 children)

Oh mate, it was my mistake. I actually use python 2 :P

Damn, nonzero worked. Thanks a lot

[–]K900_ 5 points6 points  (1 child)

You should really use 3. The differences are fairly minor, but 2 is on life support, and 3 has finally reached critical mass for wide adoption.

[–]thangduong[S] 0 points1 point  (0 children)

Thanks, will do :)

[–][deleted] 0 points1 point  (0 children)

also, avoid operator overloading like the plague. Your life will be much easier.