cosmologicon / pywat

Python wats
1.22k stars 99 forks source link

The first answer in the wat quiz is wrong #2

Closed inglesp closed 9 years ago

inglesp commented 9 years ago

You claim that x < x is impossible, but it's not:

>>> class C:
...   def __lt__(self, other):
...     return True
... 
>>> x = C()
>>> x < x
True
Futrell commented 9 years ago

The question might be interpreted as asking for a single expression, replacing ??? in the example. But you can do it with a single expression too:

>>> x = type("", (), {'__lt__': lambda self, other: True})()
>>> x < x
True
skorokithakis commented 9 years ago

Came here to file this exact issue, yep.

peter50216 commented 9 years ago

Guess that example questions still follow "Details and scope" written below, so: https://github.com/cosmologicon/pywat/blob/master/quiz.md#details-and-scope

In particular, the following are out of scope, and are not valid as missing values:

  • user-defined classes
  • lambdas
Lucas-C commented 9 years ago

I agree with @peter50216, I was about to write the same answer

skorokithakis commented 9 years ago

I feel that, if you have to say, "does anything satisfy the following, except these things that do satisfy it?", the question should probably be scrapped completely.

Lucas-C commented 9 years ago

It's there to frame the question and narrow the challenge around specific Python objects.

cosmologicon commented 9 years ago

The reason for the restriction is to avoid trick questions. Most people would probably consider type("", (), {'__lt__': lambda self, other: True})() to be a trick answer. And I'm not trying to trick people: I only want to ask questions where the answer is something reasonable.

Something where you have to come up with weird tricks like that would be fun, but it wouldn't actually test knowledge of Python edge cases, which is the whole point of the quiz.

cosmologicon commented 9 years ago

I've added this example to the quiz instructions, and tried to explain why it's considered out of scope. Hopefully that clears up the confusion.