例如,这是完美的代码.(风格是ES6)
import {List} from 'immutable';
console.log(List()); // List []
Run Code Online (Sandbox Code Playgroud)
但是,这失败了.
class Foo {}
Foo(); // TypeError: Cannot call a class as a function
Run Code Online (Sandbox Code Playgroud)
此外,这也失败了.
class Foo extends List {}
Foo(); // TypeError: Cannot call a class as a function
Run Code Online (Sandbox Code Playgroud) 我试图在python脚本中包装gnugo.
我已经讨论过关于在这里和这里包装CLI应用程序的其他问题,尽管他们有所帮助,但我还是无法让我的脚本完全运行.在stdin的第一次输入后,似乎该进程被终止.
该脚本如下所示:
import subprocess
proc = subprocess.Popen(['gnugo', '--mode', 'gtp'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
c = raw_input('first command: ')
while True:
r = proc.communicate(c)
print 'gnugo says: ' + str(r)
c = raw_input('next command: ')
Run Code Online (Sandbox Code Playgroud)
我得到的错误是这样的:
$ python testgnu.py
first command: play b c4
gnugo says: ('= \n\n', None)
next command: genmove w
Traceback (most recent call last):
File "testgnu.py", line 8, in <module>
r = proc.communicate(c)
File "/usr/local/Cellar/python/2.7.3/lib/python2.7/subprocess.py", line 754, in communicate
return self._communicate(input)
File …Run Code Online (Sandbox Code Playgroud)