I'm currently going through the excellent Python koans and I can make sense of most of them with a bit of Googling but this one has me stumped (note: the __
variable is a placeholder for the answer I have to find):
class AboutTuples(Koan):
# ....
def test_tuples_of_one_look_peculiar(self):
self.assertEqual(__, (1).__class__)
self.assertEqual(__, (1,).__class__)
self.assertEqual(__, ("Hello comma!", ))
I understand that __class__
returns the type of the expression, so in the first case this should be "a tuple containing an integer", and for the other two... I'm not quite sure, because of the comma after the first element. As it is, it fails and I get this output:
You have not yet reached enlightenment ...
AssertionError: '-=> FILL ME IN! <=-' != <class 'int'>
This is the usual answer if you've left the placeholder variable. Following this, I tried the following:
self.assertEqual("<class 'int'>", (1).__class__)
But I get the following output:
You have not yet reached enlightenment ...
AssertionError: "<class 'int'>" != <class 'int'>
So clearly it's not expecting a string, probably a type of some kind... how do I express this in Python? Is the answer similar for the other two test cases?
EDIT: Link to the exact koan, just in case