12. set とdictのリテラル >>> {1,2,3} set([1, 2, 3]) >>> {x for x in range(3)} set([0, 1, 2]) >>> {i: i*2 for i in range(4)} {0: 0, 1: 2, 2: 4, 3: 6}
13. OrderedDict >>> from collections import OrderedDict >>> d = OrderedDict([('first',1), ('second',2)]) >>> d OrderedDict([('first', 1), ('second', 2)]) >>> [x for x in d] ['first', 'second’]
15. シーケンスに含まれるかテスト self.assert_(5 in [1,2,3]) ↓ Traceback (most recent call last): File "bar.py", line 10, in test_in self.assert_(5 in [1,2,3]) AssertionError: False is not True Falesは True ではありません
16. シーケンスに含まれるかテスト new self.assertIn(5, [1,2,3]) ↓ Traceback (most recent call last): File "bar.py", line 9, in test_in self.assertIn(5, [1,2,3]) AssertionError: 5 not found in [1, 2, 3] 5 は [1,2,3] に、ない