Entries from 2008-10-11 to 1 day

学習メモ

>>> import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. R…

学習メモ

>>> a = [1, 2, 3, 4, 5] >>> a [1, 2, 3, 4, 5] >>> [item for item in a if item < 3] [1, 2] >>> filter(lambda(n): n < 3, a) [1, 2] >>>

学習メモ

>>> def square(n): ... return n**2 ... >>> a = [1, 2, 3] >>> a [1, 2, 3] >>> [square(item) for item in a] [1, 4, 9] >>> map(square, a) [1, 4, 9] >>>

学習メモ

>>> def hoge(): ... return 1 ... >>> hoge <function hoge at 0x829f0> >>> hoge() 1 >>> fuga = hoge >>> fuga <function hoge at 0x829f0> >>> fuga() 1 >>></function></function>