Drkcore

27 06 2008 jython Tweet

jythonでGenerator

trunkをコンパイル

fedora8にantが入ってなかったのでyum install antで入れた。

あとはsvn coしたらantって打つだけでOK

% ./bin/jython
Jython 2.3a0+ (trunk:4809, 6 27 2008, 21:45:52) 
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_06
Type "help", "copyright", "credits" or "license" for more information.
>>> def ytest(n):
...   for x in range(n):
...     yield x
... 
>>> it = ytest(10)
>>> it.next()
0
>>> it.next()
1
>>> it.next()
2

OK。でも2.2.1でもfrom __future__すればいけるようだ。

Jython 2.2.1 on java1.6.0_06
Type "copyright", "credits" or "license" for more information.
>>> from __future__ import generators
>>> def ytest(n):
...   for x in range(n):
...     yield x
... 
>>> it = ytest(10)
>>> it.next()
0
>>> it.next()
1

About

  • もう5年目(wishlistありマス♡)
  • 最近はPythonとDeepLearning
  • 日本酒自粛中
  • ドラムンベースからミニマルまで
  • ポケモンGOゆるめ

Tag

Python Deep Learning javascript chemoinformatics Emacs sake and more...

Ad

© kzfm 2003-2021