Ellipsisの話
某所で見て思い出した。
...ってpythonでも使えるって例。
class Test(object): def __getitem__(self, item): st = item[0] ed = item[2] return xrange(st, ed) t = Test() for i in t[1,...,10]: print i
出力
1
2
3
4
5
6
7
8
9
...はEllipsisってtypeになる。
class Test(object): def __getitem__(self, item): if item is Ellipsis: return True else: return False t = Test() print t[...] print t[0]
pythonのパーサーを特別いじるわけではないので
t[0 ... 10]
とかは書けなくて,で区切る事になる。
なのでみんな使わないんだろう。
まともに使ってるのはnumpyぐらいなもんだ。